import java.util.Scanner; public class Test { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String[] s = sc.nextLine().split("\\^"); long a, b, c, tmp, x, y; a = Long.parseLong(s[0]) % e; b = Long.parseLong(s[1]) % (e-1); c = Long.parseLong(s[2]) % (e-1); x = p(a, (b*c)%(e-1), e); tmp = p(b, c, e-1); y = p(a, tmp, e); System.out.println(x + " " + y); } public static long e = 1000000007; public static long p(long a, long b, long m){ if(a == 0){ return 0; } else if(b == 0){ return 1; } a %= m; if(b%2 == 0){ return p(a*a, b/2, m)%m; } else { return (a * p(a*a, b/2, m))%m; } } }