using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.IO.Compression; using System.Text; namespace Solver { class Program { const int M = 1000000007; static void Main() { var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; var a = Console.ReadLine().Split('^').Select(long.Parse).ToArray(); sw.WriteLine("{0} {1}", pm(pm(a[0], a[1], M), a[2], M), pm(a[0], pm(a[1], a[2], M - 1), M)); sw.Flush(); } static long pm(long a, long b, long M) { if (a >= M) return pm(a % M, b, M); if (a == 0) return 0; if (b == 0) return 1; if (b == 1) return a % M; var t = pm(a, b / 2, M); if ((b & 1) == 0) return t * t % M; else return t * t % M * a % M; } } }