a,b,c = map(int,input().split('^')) P = 10 ** 9 + 7 ans1 = pow(a,b,P) ans1 = pow(ans1,c,P) ans2 = pow(b,c,P-1) ans1 = pow(a,ans2,P) print(ans1,ans2)