n, z = map(int, input().split()) if n == 1: if z == 1: print(-1) else: print(1, z-1) else: ok = False for x in range(1, 1001): for y in range(x, 1001): if pow(x, n) + pow(y, n) == pow(z, n): print(x, y) ok = True break if ok: break if not ok: print(-1)