/*
  AOJ 2049
  Title:Headstrong Student
  @kankichi573
*/
#include <stdio.h>
#include <string.h>

int table[1000001];

main()
{
  int x,y,c,r,pos;

  while(scanf("%d %d",&x,&y) && (x||y))
    {
      memset(table,-1,sizeof(table));
      c=0;
      while(1)
	{
	  if(table[x] != -1)
	    {
	      if(x==0)
		printf("%d 0\n",c-1);
	      else
		printf("%d %d\n",table[x],c-table[x]);
	      break;
	    }
	  table[x]=c;
	  x *= 10;
	  x %= y;
	  c++;
	}
    } 	
    
  return(0);
}