a, b, c = map(int,input().split("^")) mod = 1000000007 x = pow(a, b, mod) ans1 = pow(x, c, mod) if a % mod == 0: ans2 = 0 else: y = pow(b, c, mod-1) ans2 = pow(a, y, mod) print(ans1, ans2)