#include "bits/stdc++.h" using namespace std; #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i)) #define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i)) static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL; typedef vector vi; typedef pair pii; typedef vector > vpii; typedef long long ll; template static void amin(T &x, U y) { if(y < x) x = y; } template static void amax(T &x, U y) { if(x < y) x = y; } #ifdef NDEBUG #error assert is disabled! #endif template T readNatural(T lo, T up) { assert(0 <= lo && lo <= up); T x = 0; while(1) { int d = getchar(); if(!('0' <= d && d <= '9')) { ungetc(d, stdin); break; } d -= '0'; assert(d <= up && x <= (up - d) / 10); x = x * 10 + d; } assert(lo <= x && x <= up); return x; } void readSpace() { int c = getchar(); assert(c == ' '); } void readChar(char t) { int c = getchar(); assert(c == t); } static bool read_eof = false; void readEOL() { int c = getchar(); if(c == EOF) { assert(!read_eof); read_eof = true; } else { assert(c == '\n'); } } void readEOF() { assert(!read_eof); int c = getchar(); assert(c == EOF); read_eof = true; } template struct ModInt { static const int Mod = MOD; unsigned x; ModInt() : x(0) {} ModInt(signed sig) { int sigt = sig % MOD; if(sigt < 0) sigt += MOD; x = sigt; } ModInt(signed long long sig) { int sigt = sig % MOD; if(sigt < 0) sigt += MOD; x = sigt; } int get() const { return (int)x; } ModInt &operator+=(ModInt that) { if((x += that.x) >= MOD) x -= MOD; return *this; } ModInt &operator-=(ModInt that) { if((x += MOD - that.x) >= MOD) x -= MOD; return *this; } ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; } ModInt operator+(ModInt that) const { return ModInt(*this) += that; } ModInt operator-(ModInt that) const { return ModInt(*this) -= that; } ModInt operator*(ModInt that) const { return ModInt(*this) *= that; } }; template ModInt operator^(ModInt a, unsigned long long k) { ModInt r = 1; while(k) { if(k & 1) r *= a; a *= a; k >>= 1; } return r; } typedef ModInt<1000000007> mint; typedef ModInt<1000000006> mintphi; int main() { ll A = readNatural(1LL, (ll)1e16); readChar('^'); ll B = readNatural(1LL, (ll)1e16); readChar('^'); ll C = readNatural(1LL, (ll)1e16); readEOL(); readEOF(); mint ans1 = (mint(A) ^ B) ^ C; mintphi e = mintphi(B) ^ C; mint ans2 = A % mint::Mod == 0 ? mint() : mint(A) ^ e.get(); printf("%d %d\n", ans1.get(), ans2.get()); return 0; }