p = 10**9+7 A,B,C = map(int,raw_input().split("^")) if A % p == 0: print 0,0 else: print pow(pow(A,B,p),C,p),pow(A,pow(B,C,p-1),p)