#include <iostream>
#include <map>
#include <algorithm>

using namespace std;

const int N = 1000001;

int a, b;
int p[N];
bool used[N];

int main(){
  while(cin >> a >> b && (a | b)){
    fill(used, used+N, false);
    for(int i=1;;i++){
      if(!used[a]){
        used[a] = true;
        p[a] = i;
      }else{
        cout << p[a]-1 << ' ' << i - p[a] << endl;
        break;
      }
      //cout << "! " << a << ' ' << b << endl;
      if(a % b == 0){
        cout << i-1 << ' ' << 0 << endl;
        break;
      }
      a = a*10 % b;
    }
  }
  return 0;
}