/* -*- coding: utf-8 -*- * * 403.cc: No.403 2^2^2 - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ typedef long long ll; const ll MOD = 1000000007; /* typedef */ /* global variables */ /* subroutines */ ll readnum(string &s, int &pos) { while (pos < s.size() && (s[pos] < '0' || s[pos] > '9')) pos++; ll num = 0; while (pos < s.size() && s[pos] >= '0' && s[pos] <= '9') num = num * 10 + s[pos++] - '0'; return num; } ll powmod(ll a, ll n, ll mod) { // a^n % mod ll pm = 1; while (n > 0) { if (n & 1) pm = (pm * a) % mod; a = (a * a) % mod; n >>= 1; } return pm; } /* main */ int main() { string s; cin >> s; int pos = 0; ll a = readnum(s, pos); pos++; // '^' ll b = readnum(s, pos); pos++; // '^' ll c = readnum(s, pos); //printf("%lld^%lld^%lld\n", a, b, c); // x = (a^b)^c ll ab = powmod(a % MOD, b, MOD); ll x = powmod(ab, c, MOD); // y = a^(b^c) ll bc = powmod(b % (MOD - 1), c, MOD - 1); ll y = powmod(a % MOD, bc, MOD); printf("%lld %lld\n", x, y); return 0; }