#include<stdio.h>
#include<string.h>
const int N=1000000;
int main()
{
	int x,y,r,f,i;
	while(scanf("%d%d",&x,&y),x)
	{
		static int m[1000000];
		memset(m,255,4*N);
		f=i=0;
		do
		{
			r=x%y;
			if(r==0)f=printf("%d 0\n",i);
			if(m[r]>=0)f=printf("%d %d\n",m[r],i-m[r]);
			m[r]=i;
			x=r*10;
			++i;
		}while(!f);
	}
	return 0;
}