#include <bits/stdc++.h>

using namespace std;

int check[10][1000001];

int main()
{
  int x, y;
  while(cin >> x >> y, x || y) {
    memset(check, -1, sizeof(check));
    int cnt = 0;
    x *= 10;
    bool flag = false;
    while(!~check[x/y][x%y]) {
      check[x/y][x%y] = cnt;
      if(x%y == 0) { flag = true; break; }
      cnt++;
      x %= y; x *= 10;
    }
    cout << check[x/y][x%y]+(int)flag << " " << cnt-check[x/y][x%y] << endl;
  }
  return 0;
}