a,b,c=map(int,input().split("^")) mod=10**9+7 if a%mod==0: print(0,0) exit() print(pow(pow(a,b,mod),c,mod),pow(a,pow(b,c,mod-1),mod))