import sys; input = sys.stdin.buffer.readline sys.setrecursionlimit(10**7) from collections import defaultdict con = 10 ** 9 + 7; INF = float("inf") def getlist(): return list(map(int, input().split())) from fractions import gcd #処理内容 def main(): N = int(input()) M = int(input()) GCD = gcd(N, M) n, m = int(N // GCD), int(M // GCD) mm = m cnt2, cnt5 = 0, 0 while True: if mm % 2 == 0: mm = int(mm // 2) cnt2 += 1 else: break while True: if mm % 5 == 0: mm = int(mm // 5) cnt5 += 1 else: break if mm != 1: print(-1) return if cnt2 < cnt5: for i in range(cnt5 - cnt2): n *= 2 else: for i in range(cnt2 - cnt5): n *= 5 n = list(reversed(str(n))) for i in n: if i != "0": print(i) return if __name__ == '__main__': main()