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)) if A%M else (0,0)