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