A,B,C=map(int, input().split('^')) M=10**9+7 V = [pow(pow(A,B,M),C,M),pow(A,pow(B,C,M-1),M) if A%M else 0,0] print (V[0], V[1])