import sys input=lambda: sys.stdin.readline().rstrip() D1,D2=dict(),dict() for i in range(10): for j in range(10): D1[(i,j)]=2**i*5**j D2[2**i*5**j]=(i,j) x1,x2=map(int,input().split()) while True: if 2*x1==x2 or 5*x1==x2 or x1==2*x2 or x1==5*x2: print(x2,flush=True) sys.exit() else: i1,j1=D2[x1] i2,j2=D2[x2] if (i1+j1)%2!=(i2+j2)%2: if abs(i1-i2)>abs(j1-j2): if i17: x1=D1[(i1-1,j1)] else: x1=D1[(i1+1,j1)] print(x1,flush=True) x2=int(input()) if x1==x2: sys.exit()