#include <stdio.h>
#include <string.h>

int a[1000001];

int main(void){
	int i,j,x,y,p,q,flg;

	while(scanf("%d%d",&x,&y) && (x||y)){
		flg = 0; //1:ツ循ツ甘つつキツづゥ 0:ツ循ツ甘つつオツづ按つ「
		memset(a,-1,sizeof(a));

		for(i=0;;i++){
			x = x - y * (x / y);
			if(x == 0) break;
			if(a[x] != -1){
				flg = 1;
				j = a[x];
				break;
			}
			a[x] = i;
			x *= 10;
		}

		printf("%d %d\n",flg ? j : i, flg ? i-j : 0);
	}

  return 0;
}