#include
using namespace std;
#define ll long long
ll ksm(ll a,ll b,ll n)
{
ll ans = 1;
ll t = a%n; // a^b % n = (a%n)^b % n
while(b)
{
if(b&1)
ans = (ans * t)%n ;
t = (t*t)%n;
b >>=1;
}
return ans;
}
int main()
{
cout << ksm(2,7,7) <