#include #include #include using namespace std; int cache[1024 * 1024]; int main() { ifstream cin("B.txt"); int x, y; while (cin >> x >> y && y) { assert(0 < x && x <= 1000000); assert(0 < y && y <= 1000000); assert(x < y); // x %= y; memset(cache, -1, sizeof(cache)); for (int i = 0; ; ++i) { if (x == 0) { cout << i << " " << 0 << endl; break; } if (cache[x] >= 0) { cout << cache[x] << " " << i - cache[x] << endl; break; } cache[x] = i; x = x * 10 % y; } } }