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