#include<bits/stdc++.h>
#define N 10000005
using namespace std;
int m[N];
int a,b,cnt,ans1,ans2;

int main(){
  while(1){
    cin>>a>>b;
    if(!a&&!b)break;
    memset(m,-1,sizeof(m));
    a%=b;
    cnt=0;
    while(1){
      a*=10;
      if(m[a]!=-1){
	ans1=m[a],ans2=cnt-m[a];
	break;
      }
      m[a]=cnt;
      a%=b;
      if(!a){
	ans1=cnt+1,ans2=0;
	break;
      }      
      cnt++;
    }
    cout<<ans1<<' '<<ans2<<endl;
  }
  return 0;
}