import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines A,B,C = map(int,read().split(b'^')) MOD = 10 ** 9 + 7 x = pow(A,B,MOD) x = pow(x,C,MOD) y = pow(B,C,MOD-1) y = pow(A,y,MOD) print(x,y)