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<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
int n,Mod;
void add(int& x,int y)
{
	x+=y;
	if(x>=Mod)x-=Mod;
	return ;
}
int A[510],B[510];
int f[510][510];
int calc(int x,int a,int b)
{
	int res=1;
	for(int i=A[x];i>A[x+1];i--)
	{
		int cur=n*2-i;
		if(x-a-cur<0)res=0;
		res=(long long)res*(x+1-a-cur+Mod)%Mod;
	}
	for(int i=B[x];i>B[x+1];i--)
	{
		int cur=n*2-i;
		if(A[i-1]-b-cur<0)res=0;
		res=(long long)res*(A[i-1]-b-cur+Mod)%Mod;
	}
//	if(!a&&!b){
//		printf("calc(%d)=%d\n",x,res);
//	}
	return res;
}
int solve(int m)
{
	//choose exactly m
	memset(f,0,sizeof(f));
	f[0][0]=1;
	for(int i=0;i<n;i++)
		for(int j=0;j<=m;j++)
		{
			add(f[i+1][j],(long long)f[i][j]*calc(i,j,m-j)%Mod);
			if(j<m)add(f[i+1][j+1],(long long)f[i][j]*calc(i,j+1,m-j-1)%Mod);
		}
	int ans=f[n][m];
	for(int i=A[n];i>B[0];i--)
	{
		int cur=n*2-i;
		if(A[i-1]-m-cur+Mod<0)ans=0;
		ans=(long long)ans*(A[i-1]-m-cur+Mod)%Mod;
	}
//	printf("%d:%d\n",m,ans);
	return ans;
}
int main()
{
	scanf("%d %d",&n,&Mod);
	for(int i=0;i<n*2;i++)
	{
		while(A[i]<(n*2)&&A[i]*A[i]+i*i<=(n*2)*(n*2))
			A[i]++;
		while(B[i]<n&&B[i]*B[i]+i*i<n*n)
			B[i]++;
	}
	int ans=0;
	for(int i=0;i<=n;i++)
		if(i&1)ans=(ans-solve(i)+Mod)%Mod;
		else ans=(ans+solve(i))%Mod;
	printf("%d\n",ans);
	return 0;
}