A, B, C = map(int, raw_input().split('^')); MOD = 1000000007; vl = pow(pow(A, B, MOD), C, MOD); vr = pow(A, pow(B, C, MOD-1), MOD); print ' '.join(map(str, [vl if A%MOD else 0, vr if A%MOD else 0]));