using System; using System.Collections.Generic; using System.Linq; class Magatro { const int MOD = 1000000007; static long A, B, C; static void Main() { long[] q = Console.ReadLine().Split('^').Select(s => long.Parse(s)).ToArray(); A = q[0]; B = q[1]; C = q[2]; A %= MOD; Console.Write(Pow(Pow(A, B,MOD), C,MOD)%MOD); Console.Write(" "); Console.Write(Pow(A, Pow(B, C, MOD - 1), MOD)); Console.WriteLine(); } static long Pow(long x,long y,int mod) { long ans=x%mod; if (ans == 0) { return 0; } long q = 1; while (y > 1) { long a = ans; for(long l=2;true;l*=2) { a = (a * a) % mod; if (l * 2 > y) { y -= l; break; } } q = (q * a) % mod; } if (y == 1) { q = (q * (x % mod)) % mod; } return q; } }