#include<cstdio>
#include<cstring>
#define MAXN 10000000
int vis[MAXN];
int main() {
	int a, b, x, y, t;
	while (~scanf("%d%d", &a, &b)) {
		memset(vis, 0, sizeof(vis));
		a -= a / b * b;
		x = y = 0;
		while (a < b) {
			a *= 10;
			x++;
		}
		for (; a;) {
			a %= b;
			if (a == 0)
				break;
			while (a < b) {
				a *= 10;
				x++;
			}
			if (vis[a])
				break;
			else
				vis[a] = x;
		}
		printf("%d %d\n", vis[a], x - vis[a]);
	}
	return 0;
}