package No400番台; import java.util.Arrays; import java.util.Scanner; public class Main{ public static void main(String[] args) { solver(); } static long MOD = 1_000_000_000 + 7; static void solver() { Scanner sc = new Scanner(System.in); String[] s = sc.next().split("\\^"); long a = Long.parseLong(s[0]); long b = Long.parseLong(s[1]); long c = Long.parseLong(s[2]); if (a % MOD == 0) { System.out.println(0 + " " + 0); return; } System.out.println( pow(a, (b % (MOD - 1)) * (c % (MOD - 1)) % (MOD - 1), MOD) + " " + pow(a, pow(b, c, MOD - 1), MOD)); } static long pow(long a, long n, long mod) { long A = a % mod; long ans = 1; for (; n >= 1; n >>= 1, A *= A, A %= mod) { if ((n & 1) == 1) { ans *= A; ans %= mod; } } return ans; } static void tr(Object... o) { System.out.println(Arrays.deepToString(o)); } }