#include <cstdio>#define ll long long#define int long longint x, y, p;int qp(int x, int y, int p) { int res = 1; for(; y; y >>= 1, x = x*x%p) if(y&1) res = res*x%p; return res%p;}signed main() { scanf("%lld%lld%lld", &x, &y, &p); printf("%lld^%lld mod %lld=%lld\n", x, y, p, qp(x, y, p));}