mod = 1000000007 def solve(): A, B, C = map(int, input().split('^')) ans1 = pow(pow(A, B, mod), C, mod) ans2 = pow(A, pow(B, C, mod - 1), mod) print(ans1, ans2) if __name__ == '__main__': solve()