#include using namespace std; typedef long long LL; int a, b, p; LL qmi(LL x, LL y, LL p) { LL res = 1; while (y) { if (y & 1) res = res * x % p; y >>= 1; x = x * x % p; } return res; } int main() { scanf("%d %d %d", &a, &b, &p); printf("%d^%d mod %d=%lld\n", a, b, p, qmi(a, b, p)); return 0; }