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 long long LL;
int _max(int x, int y) {return x > y ? x : y;}
int _min(int x, int y) {return x < y ? x : y;}
const int N = 251;
int mod;
int read() {
	int s = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
	return s * f;
}
void put(int x) {
	if(x < 0) x = -x, putchar('-');
	if(x >= 10) put(x / 10);
	putchar(x % 10 + '0');
}

struct node {int c, id;} sta[N * 2];
int f[N], c[N];

int add(int x, int y) {
	x += y;
	return x >= mod ? x - mod : x;
}

int dec(int x, int y) {
	x -= y;
	return x < 0 ? x + mod : x;
}

bool cmp(node a, node b) {
	if(a.c == b.c) return a.id > b.id;
	return a.c < b.c;
}

int main() {
	int n = read(); mod = read();
	int tp = 0;
	for(int i = n - 1; i >= 0; i--) {
		while(tp < 2 * n && tp * tp + i * i < n * n) tp++;
		sta[i] = node{tp, i}; 
	} tp = 0;
	for(int i = (n << 1) - 1; i >= n; i--) {
		while(tp < 2 * n && tp * tp + i * i <= 4 * n * n) tp++;
		sta[i] = node{tp, -1};
	} for(int i = n - 1; i >= 0; i--) {
		while(tp < 2 * n && tp * tp + i * i <= 4 * n * n) tp++;
		c[i] = tp;
	} sort(sta, sta + 2 * n, cmp);
	int ans = 0;
	for(int k = 0; k <= n; k++) {
		memset(f, 0, sizeof(f)); f[0] = 1;
		int u = 0, v = 0;
		for(int i = 0; i < 2 * n; i++) {
			if(sta[i].id == -1) {
				for(int j = 0; j <= _min(v, k); j++) f[j] = (LL)f[j] * _max(0, sta[i].c - u - j) % mod;
				u++;
			} else {
				for(int j = _min(v, k); j >= 0; j--) {
					if(j < k) f[j + 1] = add(f[j + 1], (LL)f[j] * _max(0, sta[i].c - u - j) % mod);
					f[j] = (LL)f[j] * _max(0, c[sta[i].id] - (n + k + v - j)) % mod;
				} v++;
			}
		} ans = k & 1 ? dec(ans, f[k]) : add(ans, f[k]);
	} put(ans), puts("");
	return 0;
}

