computing ( a ^ b ) % c
long long int modpow ( long long int base , long long int exp , long long int modulus ) { base %= modulus ; long long int result = 1 ; while ( exp > 0 ) { if ( exp & 1 ) result = ( result * base ) % modulus ; base = ( base * base ) % modulus ; exp >>= 1 ; } return result ; }