#!/usr/bin/python3 mod = 10**9 + 7 def f1(a, b, c): return pow(pow(a, b, mod), c, mod) def f2(a, b, c): bc = b**c if bc >= mod - 1: return pow(a % mod, bc % (mod-1) + (mod-1), mod) else: return pow(a, bc, mod) a, b, c = map(int, input().split('^')) r1 = f1(a, b, c) r2 = f2(a, b, c) print(r1, r2)