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 mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
int n,m;
ll dp[700][700];
void add(ll &a,ll b)
{
	b%=m;
	a+=b;
	if(a>=m)a-=m;
}
int upb[700],lwb[700],od[700];
bool less2(int a,int b)
{
	int va=(a<n)?lwb[a]:upb[a];
	int vb=(b<n)?lwb[b]:upb[b];
	if(va!=vb) return va<vb;
	return a>b;
}
int main()
{
	cin>>n>>m;
	upb[0]=n*2-1;
	lwb[0]=n-1;
	for(int i=1;i<n;i++)
	{
		upb[i]=upb[i-1];
		lwb[i]=lwb[i-1];
		while((upb[i]*upb[i]+i*i)>4*n*n)upb[i]--;
		while((lwb[i]>=0)&&((lwb[i])*(lwb[i])+i*i)>=n*n)lwb[i]--;
	}
	for(int i=n;i<n*2;i++)
	{
		upb[i]=upb[i-1];
		while((upb[i]*upb[i]+i*i)>4*n*n)upb[i]--;
	}
	for(int i=0;i<n*2;i++)
	{
//		cout<<i<<" "<<lwb[i]<<" "<<upb[i]<<endl;
	}
//	system("pause");
	for(int i=0;i<n*2;i++)
	{
		od[i]=i;
	}
	ll ans=0;
	sort(od,od+n*2,less2);
	for(int k=0;k<=n;k++)
	{
	//	cout<<"dp "<<k<<endl;
		memset(dp,0,sizeof(dp));
		dp[0][0]=1;
		for(int i=0;i<n*2;i++)
		{
			int ri=od[i];
			for(int j=0;j<=k&&j<=i;j++)
			{
				if(ri>=n)
				{
					add(dp[i+1][j],dp[i][j]*(upb[ri]+1-(j+(2*n)-ri-1)%m));
				//	cout<<i<<" "<<j<<" "<<ri<<" "<<upb[ri]+1<<" "<<(j+2*n-ri-1)<<endl;
				//	system("pause");
				}
				else
				{
					//up
					if(j+ri>=k)
					{
						add(dp[i+1][j],dp[i][j]*(upb[ri]+1-(n+k+n-ri-j-1))%m);
				//		cout<<i<<" "<<j<<" "<<ri<<" "<<upb[ri]+1<<" "<<n+k+n-ri-j-1<<" "<<n+k-1<<" "<<n-ri-j<<endl;
				//		system("pause");
					}
					//lw
					if(j+1<=k)
					{
						add(dp[i+1][j+1],dp[i][j]*(lwb[ri]+1-(i-(n-ri-j)+1))%m);
				//		cout<<i<<" "<<j<<" "<<ri<<" "<<lwb[ri]+1<<" "<<i-(n-ri-j)+1<<endl;
				//		system("pause");
					}
				}
			}
		}
		ll val=dp[n*2][k];
		if(k&1)val=m-val;
		add(ans,val);
	}
	printf("%lld\n",ans);
	return 0;
}