N = int(input()) M = int(input()) for _ in range(0, 50) : x = N // M if x * M == N: s = str(x) ans = '' for c in s : if c != '0' : ans = c print(ans) quit() N *= 10 print(-1)