import java.util.*; public class Main { static Scanner sc = new Scanner(System.in); static void myout(Object t){System.out.println(t);}//standard output static void myerr(Object t){System.err.println(t);}//standard error static String getStr(){return sc.next();} static int getInt(){return Integer.parseInt(getStr());} static long getLong(){return Long.parseLong(getStr());} static boolean hasNext(){return sc.hasNext();} static char[] mySplit(String str){return str.toCharArray();} public static void main(String[] args){ char[] tmp = mySplit(getStr()); String strA = ""; String strB = ""; String strC = ""; boolean accessA = false; boolean accessB = false; for(int i = 0; i < tmp.length; i++){ if(!accessA){ if(tmp[i] != '^'){ strA += tmp[i]; }else{ accessA = true; } }else if(!accessB){ if(tmp[i] != '^'){ strB += tmp[i]; }else{ accessB = true; } }else{ strC += tmp[i]; } } long mod = 1000000007; long A = Long.parseLong(strA) % mod; long B = Long.parseLong(strB) % mod; long C = Long.parseLong(strC) % mod; myout(originPow(originPow(A,B,mod),C,mod) + " " + originPow(A,originPow(B,C,mod - 1),mod)); } //Method addition frame start static long originPow(long x, long n) {return originPow(x,n,-1);} static long originPow(long x, long n, long m) { long ans = 1; while (n > 0) { if ((n & 1) == 1){ ans = ans * x; if(m != -1){ans %= m;} } x = x * x; if(m != -1){x %= m;} n >>= 1; } return ans; } //Method addition frame end }