using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Text; using System.Text.RegularExpressions; using System.Linq; class Magatro { static long A, B, C; const long mod = 1000000007; static void Main() { string[] s = Console.ReadLine().Split('^'); A = long.Parse(s[0]); B = long.Parse(s[1]); C = long.Parse(s[2]); Console.WriteLine("{0} {1}", MyPow(MyPow(A, B, mod), C, mod), MyPow(A, MyPow(B, C, mod - 1), mod)); } static long MyPow(long a,long b,long mod) { a %= mod; long ret = 1; while (b > 0) { if (b % 2 == 0) { a = (a * a) % mod; b /= 2; } else { ret = (ret * a) % mod; b--; } } return ret; } }