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]); c = Long.parseLong(s[2]); tmp = ((b%(e-1))*(c%(e-1)))%(e-1); x = p(a, tmp, e); tmp = p(b%(e-1), c%(e/2-1), 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){ a %= m; if(a == 0){ return 0; } else if(b == 0){ return 1; } if(b%2 == 0){ return p(a*a, b/2, m)%m; } else { return (a * p(a*a, b/2, m))%m; } } }