Given is an integer N. How many permutations (P_0,P_1,\cdots,P_{2N-1}) of (0,1,\cdots,2N-1) satisfy the following condition?

* For each i (0 \leq i \leq 2N-1), N^2 \leq i^2+P_i^2 \leq (2N)^2 holds.



Since the number can be enormous, compute it modulo M.

Constraints

* 1 \leq N \leq 250
* 2 \leq M \leq 10^9
* All values in input are integers.

Input

Input is given from Standard Input in the following format:


N M


Output

Print the number of permutations that satisfy the condition, modulo M.

Examples

Input

2 998244353


Output

4


Input

10 998244353


Output

53999264


Input

200 998244353


Output

112633322
#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

ll mod;
ll dp[600][300];

int main() {
	int N, M; cin >> N >> M;
	mod = M;

	vector<pii> vec;
	vi mx(N);

	for (int i = 0; i < N * 2; ++i) {
		if (i < N) {
			int p = 0;
			for (int x = 0; x < N * 2; ++x) {
				if (i * i + x * x < N * N) {
					p = x + 1;
				}
			}
			vec.eb(p, -i);
		}

		int q = 0;
		for (int y = 0; y < N * 2; ++y) {
			if (i * i + y * y <= N * N * 4) {
				q = y + 1;
			}
		}
		if (i < N) mx[i] = q;
		else vec.eb(q, -i);
	}

	sort(ALL(vec));

	int sz = vec.size();

	ll ans = 0;

	for (int ban = 0; ban <= N; ++ban) {
		memset(dp, 0, sizeof(dp));

		dp[0][0] = 1;
		int big = 0;

		rep(i, sz) {
			for (int j = 0; j <= min(i, ban); ++j) {
				if (dp[i][j] == 0) continue;
			//ng
				if (vec[i].se <= 0 && vec[i].se > -N) {
					dp[i+1][j+1] += dp[i][j] * max<ll>(0, vec[i].fi - big - j);
				}
			//ok
				if (vec[i].se <= -N) {	
					dp[i+1][j] += dp[i][j] * max<ll>(0, vec[i].fi - big - j);
				} else {
					dp[i+1][j] += dp[i][j] * max<ll>(0, mx[-vec[i].se] - (N + ban + (i - j - big)));
				}
				dp[i+1][j+1] %= mod;
				dp[i+1][j] %= mod;
			}
			if (vec[i].se <= -N) ++big;
		}

		ll way = dp[sz][ban];

		if (ban & 1) way = mod - way;
		ans = (ans + way) % mod;
	}

	cout << ans << endl;

	return 0;
}