A,B,C = map(int,input().split('^')) mod = 10**9+7 if A % mod == 0: print(0,0) else: X = pow(A,B*C,mod) Y = pow(A,pow(B,C,mod-1),mod) print(X,Y)