a, b, c = map(int, input().split('^')) mod = 10**9 + 7 print(pow(pow(a, b, mod), c, mod), pow(a, pow(b, c, mod-1), mod))