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-1)+M-1,M))