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>
#define fi first
#define se second
using namespace std;

const int maxn = 500;
int n, mod, L[maxn + 3], R[maxn + 3], dp[maxn + 3][maxn + 3];
pair<int, int> a[maxn + 3];

int get(int x, int y) {
	int z = 0;
	while (z < n * 2 - 1 && (z + 1) * (z + 1) + x <= y) {
		z++;
	}
	return z;
}

int solve(int k) {
	/*
	puts("-----");
	printf("solve %d\n", k);
	*/
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	int A = 0, C = 0;
	for (int i = 0; i < n * 2; i++) {
		// printf("! %d %d %d\n", i, a[i].fi, a[i].se);
		if (~a[i].se) {
			for (int j = 0; j <= A; j++) {
				dp[i + 1][j + 1] = (dp[i + 1][j + 1] + 1ll * dp[i][j] * (a[i].fi - j - C)) % mod;
			}
			for (int j = 0; j <= A; j++) {
				dp[i + 1][j] = (dp[i + 1][j] + 1ll * dp[i][j] * (a[i].se - k - n - (A - j))) % mod;
			}
			A++;
		} else {
			for (int j = 0; j <= A; j++) {
				dp[i + 1][j] = (dp[i + 1][j] + 1ll * dp[i][j] * (a[i].fi - j - C)) % mod;
			}
			C++;
		}
		/*
		for (int j = 0; j <= A; j++) {
			printf("%d %d %d\n", i, j, dp[i][j]);
		}
		*/
	}
	/*
	for (int j = 0; j <= A; j++) {
		printf("%d %d %d\n", n * 2, j, dp[n * 2][j]);
	}
	*/
	return dp[n * 2][k];
}

int main() {
	scanf("%d %d", &n, &mod);
	for (int i = 0; i < n; i++) {
		a[i] = make_pair(get(i * i, n * n - 1) + 1, get(i * i, n * n * 4) + 1);
	}
	for (int i = n; i < n * 2; i++) {
		a[i] = make_pair(get(i * i, n * n * 4) + 1, -1);
	}
	sort(a, a + n * 2);
	/*
	for (int i = 0; i < n * 2; i++) {
		printf("%d %d\n", a[i].fi, a[i].se);
	}
	*/
	int ans = 0;
	for (int i = 0; i <= n; i++) {
		ans = (ans + 1ll * (i & 1 ? mod - 1 : 1) * solve(i)) % mod;
	}
	printf("%d\n", ans);
	return 0;
}