a,b,c = map(int,input().split("^")) MOD=10**9+7 print(str(pow(pow(a,b,MOD),c,MOD))+" "+str(pow(a,pow(b,c,MOD),MOD)))