import java.util.*; public class Main { static final int MOD = 1000000007; static final int MODN = MOD - 1; public static void main(String[] args) { Scanner sc = new Scanner(System.in); String line = sc.nextLine(); int idx = line.indexOf('^'); long a = Long.parseLong(line.substring(0, idx)) % MOD; int next = line.indexOf('^', idx + 1); long b = Long.parseLong(line.substring(idx + 1, next)); long c = Long.parseLong(line.substring(next + 1, line.length())); long x = pow(pow(a, b), c); long y = pow(a, powmod(b % MOD, c)); System.out.println(x + " " + y); } static long pow(long x, long p) { if (p == 0) { return 1; } else if (p % 2 == 0) { return pow(x * x % MOD, p / 2); } else { return pow(x, p - 1) * x % MOD; } } static long powmod(long x, long p) { if (p == 0) { return 1; } else if (p % 2 == 0) { return powmod(x * x % MODN, p / 2); } else { return powmod(x, p - 1) * x % MODN; } } }