def x_to_cnt(x): cnt2,cnt5=0,0 while x%2==0: x//=2 cnt2+=1 while x%5==0: x//=5 cnt5+=1 return cnt2,cnt5 def cnt_to_x(cnt2,cnt5): return 2**cnt2*5**cnt5 x1,x2=map(int,input().split()) for _ in range(35): assert 10**9%x1==0 assert 10**9%x2==0 if x1==x2: exit() c12,c15=x_to_cnt(x1) c22,c25=x_to_cnt(x2) if abs(c12-c22)>=abs(c15-c25): if c12c22: x1//=2 else: assert False else: if c15c25: x1//=5 else: assert False print(x1) if x1==x2: exit() if _!=34: x2=int(input())