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 <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;

typedef long long ll;
const int Maxn = 500;

int N, Mod;

vector<pair<int, int> > p;
ll f[Maxn + 5][Maxn + 5];

inline int F(int i) {
	static int ret = 2 * N - 1;
	while(ret >= 0 && i * i + ret * ret > 4 * N * N)
		ret--;
	return ret + 1;
}
inline int G(int i) {
	static int ret = 2 * N - 1;
	while(ret >= 0 && i * i + ret * ret >= N * N)
		ret--;
	return ret + 1;
}

int main()
{
	scanf("%d %d", &N, &Mod);
	for(int i = 0; i <= 2 * N - 1; i++) {
		if(i < N) p.push_back(make_pair(G(i), F(i)));
		else p.push_back(make_pair(F(i), 0));
	}
	sort(p.begin(), p.end());
	ll ans = 0;
	for(int k = 0; k <= N; k++) {
		memset(f, 0, sizeof f);
		f[0][0] = 1;
		int cnt1 = 0, cnt2 = 0;
		for(int i = 0; i < (int)p.size(); i++) {
			for(int j = 0; j <= k; j++)
				if(p[i].second == 0) {
					f[i + 1][j] = (f[i + 1][j] + f[i][j] * (p[i].first - j - cnt1) % Mod) % Mod;
				} else {
					if(j < k) f[i + 1][j + 1] = (f[i + 1][j + 1] + f[i][j] * (p[i].first - j - cnt1) % Mod) % Mod;
					f[i + 1][j] = (f[i + 1][j] + f[i][j] * (p[i].second - N - k - (cnt2 - j)) % Mod) % Mod;
				}
			if(p[i].second == 0) cnt1++;
			else cnt2++;
		}
		if(k % 2) ans = (ans - f[p.size()][k] + Mod) % Mod;
		else ans = (ans + f[p.size()][k]) % Mod;
	}
	printf("%lld\n", ans);
}