#include<bits/stdc++.h>
#define LL long long
using namespace std;
LL fast_power(LL a,LL b,LL c){
LL ans=1;
a%=c;
while(b){
if(b&1){
ans=(ans*a)%c;
}else{
a=(a*a)%c;
b>>1;
}
}
return ans;
}
int main(){
LL a,b,c;
scanf("%lld %lld %lld",&a,&b,&c);
LL ans=fast_power(a,b,c);
ans%=c;
printf("%lld^%lld mod %lld=%lld",a,b,c,ans);
return 0;
}