ソースコード
#define _USE_MATH_DEFINES
#include <iostream>
#include <math.h>
#include <climits>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MD = 1000000007;
/* sample input
*/
ll mod_pow(ll x, ll n, ll mod) {
if (n == 0) return 1;
ll res = mod_pow(x*x%mod, n / 2, mod);
if (n & 1) res = res*x%mod;
return res;
}
int main()
{
ll a, n;
ll answer;
cin >> a >> n;
//a^n%MDを求める?
answer = a;
/*
for (ll i = 0; i < n - 1; i++) {
answer = (answer*a) % MD;
}
*/
cout << mod_pow(a,n,MD);
return 0;
}