A,B,C=map(int,input().split('^')) mod=1000000007 if A%mod==0: print(0,0) exit() K=pow(B,C,mod-1) T=B*C%(mod-1) print(pow(A,T,mod),pow(A,K,mod))