MOD = 10 ** 9 + 7 a, b, c = map(int, input().split("^")) if a % MOD == 0: print("0 0") exit() ans = [] ans.append(pow(pow(a, b, MOD), c, MOD)) ans.append(pow(a, pow(b, c, MOD - 1), MOD)) print(*ans, sep=" ")