a,b,c=gets.split(?^).map &:to_i d=10**9+7 print (a**b)**c%d," ",a**(b**c)%d