#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#include <fstream>
#include <map>
#include <cstring>

using namespace std;


char ap[1000001];

int main(){

	int x,y;
	while(cin>>x>>y&&(x|y)){
		memset(ap,-1,sizeof(ap));
		int a,b;
		a=0;
		b=0;
		x*=10;
		int sz=0;
		ap[x/10]=sz++;
		while(1){
			if(x<y)x*=10;
			else{
				x=x%y;
				x*=10;
			}
			if(x==0){
				cout<<sz<<" "<<0<<endl;
				break;
			}
			if(ap[x/10]==-1)ap[x/10]=sz++;
			else{
				int i=ap[x/10];
				int band=sz-i;
				a=i;
				b=band;
				cout<<a<<" "<<b<<endl;
				break;
			}
		}
	}

	return 0;
}