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;
int n, mod, f[505][255][255], L[505], R[505];
pair<int, int> a[505];
inline void Add(int &x, int y) {
	x += y;
	if (x >= mod) x -= mod;
}
inline void Sub(int &x, int y) {
	x -= y;
	if (x < 0) x += mod;
}
int main() {
	scanf("%d%d", &n, &mod);
	for (int i = 0; i < 2 * n; i++) {
		int j;
		for (j = 0; j < 2 * n && i * i + j * j <= 4 * n * n; j++);
		R[i] = j - 1;
		if (i < n) {
			for (j = 0; j < 2 * n && i * i + j * j < n * n; j++);
			L[i] = j;
			a[i] = make_pair(L[i] - 1, R[i]);
		} else {
			L[i] = 0;
			a[i] = make_pair(R[i], -1);
		}
	}
	sort(a, a + 2 * n);
	for (int j = 0; j <= n; j++) f[0][j][j] = 1;
	for (int i = 0, u = 0, v = 0; i < 2 * n; i++) {
		a[i].first++;
		a[i].second++;
		for (int j = 0; j <= n; j++) {
			for (int k = 0; k <= j; k++) if (f[i][j][k]) {
				if (!a[i].second) {
					if (a[i].first - u - j + k > 0) Add(f[i + 1][j][k], 1ll * f[i][j][k] * (a[i].first - u - j + k) % mod);
				} else {
					if (k && a[i].first - u - j + k > 0) Sub(f[i + 1][j][k - 1], 1ll * f[i][j][k] * (a[i].first - u - j + k) % mod);
					if (a[i].second - n - v - k > 0) Add(f[i + 1][j][k], 1ll * f[i][j][k] * (a[i].second - n - v - k) % mod);
				}
			}
		}
		if (!a[i].second) u++;
		else v++;
	}
	int ans = 0;
	for (int j = 0; j <= n; j++) Add(ans, f[2 * n][j][0]);
	printf("%d\n", ans);
	return 0;
}