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