from collections import * from itertools import * from functools import * from heapq import * import sys,math input = sys.stdin.readline mod = 10**9 + 7 a,b,c = (map(int,input().split('^'))) X = [] X.append(pow(a,b*c,mod)) y = pow(b,c,mod-1) X.append(pow(a,y,mod)) print(*X)