#include using namespace std; long M = 1e7; long pow(long x, long n){ long ret = 1; while(n > 0){ if(n & 1) ret = ret * x % M; x = x * x % M; n >>= 1; } return ret; } int main(){ long a, n; cin >> a >> n; cout << M << endl; cout << pow(a, n); }