#include namespace { #pragma GCC diagnostic ignored "-Wunused-function" #include #pragma GCC diagnostic warning "-Wunused-function" using namespace std; using namespace atcoder; #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--) #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) template bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; } template bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; } using ll = long long; using P = pair; using VI = vector; using VVI = vector; using VL = vector; using VVL = vector; constexpr int pow5(int e) { int res = 1; rep(_, e) res *= 5; return res; } template void solve(int n) { if (e == 0) { cout << 0 << '\n'; return; } constexpr int mod = pow5(e); using mint = static_modint; constexpr int mx = (mod + 1) / 2; mint tgt = n; for(int i = 0; i <= mx; i++) { mint r = mint::raw(i); mint r2 = r * r; if (r2 == tgt) { cout << r.val() << '\n'; return; } } cout << "NaN\n"; } template void select_solver(int n, int e_in) { if (e_in == e) solve(n); else select_solver(n, e_in); } template<> void select_solver<-1>(int, int) { assert(false); } } int main() { ios::sync_with_stdio(false); cin.tie(0); int n, e; cin >> n >> e; select_solver<13>(n, e); cout << flush; }