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 meow(args...) fprintf(stderr, args)
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, (c>9)&(c!=253));
	for(a=(b=c==253)?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
int (*rd)()=read<int>;

const int N=501;
int l[N], r[N], p[N], f[N];
int main() {
	int n, m, ans=0;
	n=rd(), m=rd();
	for(int i=0; i<n; ++i) {
		l[i]=(int)sqrt(n*n-i*i);
		if(l[i]*l[i]==n*n-i*i) --l[i];
		r[i]=(int)sqrt(4*n*n-i*i);
		if(r[i]==2*n) --r[i];
	}
	for(int i=n; i<2*n; ++i) l[i]=(int)sqrt(4*n*n-i*i);
	for(int i=0; i<2*n; ++i) p[i]=i;
	std::sort(p, p+2*n, [](int x, int y) {return l[x]<l[y]||l[x]==l[y]&&r[x]<r[y];});
	for(int k=0; k<=n; ++k) {
		int cnt=0;
		f[0]=1;
		memset(f+1, 0, k*sizeof(int));
		for(int i=0; i<2*n; ++i)
			if(p[i]<n) {
				for(int j=cnt; j>=0; --j) {
					f[j+1]=(f[j+1]+(s64)f[j]*(l[p[i]]-i-j+cnt+1))%m;
					f[j]=(s64)f[j]*(r[p[i]]-2*n+p[i]-k+j+2)%m;
				}
				++cnt;
			} else
				for(int j=0; j<=cnt; ++j)
					f[j]=(s64)f[j]*(l[p[i]]-i-j+cnt+1)%m;
		ans=(ans+(k&1?-1:1)*f[k])%m;
	}
	if(ans<0) ans+=m;
	printf("%d\n", ans);
	return 0;
}
