static long modpow(long a,long b,long c){
//..to calculate a^b%c
long ans = 1;
do{
if(b%2==1){
ans = ans*a%c;
}
b = b>>1;
a = a*a%c;
}while(b!=0);
return ans;
}
//..to calculate a^b%c
out.println(BigInteger.valueOf(a).modPow(BigInteger.valueOf(b),BigInteger.valueOf(c)));