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