inp = input().split("^") a = int(inp[0]) b = int(inp[1]) c = int(inp[2]) M = 1000000007 if a % M == 0 : print("0 0") else : print(pow(pow(a, b, M), c, M), pow(a, pow(b, c, M-1), M))