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;
#define ri register int
typedef long long ll;
const int N=255;
int mod,f[N*2][N],c1,c2;
pair<int,int> a[N*2];
#define fi first
#define se second
inline int mul(ri x,ri y){
	return (ll)x*y%mod;
}
inline void add(int &x,ri y){
	x=(x+=y)>=mod?x-mod:x;
}
int main(){
	ri n,i,j,k,lstg,lstf,ans;
	scanf("%d%d",&n,&mod);
	lstg=lstf=2*n-1;
	for(i=0;i<n;++i){
		while(lstg*lstg+i*i>= n*n) --lstg;
		while(lstf*lstf+i*i>4*n*n) --lstf;
		a[i+1]=make_pair(lstg+1,lstf+1);
	//	printf("%d %d\n",a[i+1].fi,a[i+1].se);
	}
	for(;i<2*n;++i){
		while(lstf*lstf+i*i>4*n*n) --lstf;
		a[i+1]=make_pair(lstf+1,0);
	//	printf("%d %d\n",a[i+1].fi,a[i+1].se);
	}
	sort(a+1,a+1+2*n);
	f[0][0]=1;
	ans=0;
	for(k=0;k<=n;++k){
		for(i=1;i<=2*n;++i)
			for(j=0;j<=k&&j<=i;++j)
				f[i][j]=0;
		c1=c2=0;
		for(i=1;i<=2*n;++i){
			if(!a[i].se){
				for(j=0;j<=c2&&j<=k;++j)
					if(a[i].fi-(j+c1)>0)
						add(f[i][j],mul(f[i-1][j],a[i].fi-(j+c1)));
				++c1;
			}
			else{
				for(j=0;j<=c2&&j+1<=k;++j)
					if(a[i].fi-(j+c1)>0)
						add(f[i][j+1],mul(f[i-1][j],a[i].fi-(j+c1)));
				for(j=0;j<=c2;++j)
					if(a[i].se-(n+k+c2-j)>0)
						add(f[i][j],mul(f[i-1][j],a[i].se-(n+k+c2-j)));
				++c2;
			}
		//	for(j=0;j<=c2;++j)
		//		printf("f %d %d %d\n",i,j,f[i][j]);
		}
	//	printf("%d %d\n",k,f[2*n][k]);
		ans=(ans+(ll)(k&1?mod-1:1)*f[2*n][k])%mod;
	}
	printf("%d\n",ans);
	return 0;
}