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 ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;

const int maxn=511;
int n,mod;
inline void add(int&x,int y){x+=y;if(x>=mod)x-=mod;}
int f[maxn],g[maxn];

int dp[255][255],sum[255];
vector<int> have[255];
int calc(int x)
{
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	for(int i=0;i<n;i++)for(int j=0;j<n;j++)if(dp[i][j])
	{
		int coef,cur;
		coef=1;cur=sum[i]+j;
		for(auto v:have[i])
		{
			coef=(LL)coef*max(0,v-cur+1)%mod;
			cur++;
		}
		coef=(LL)coef*max(0,g[i]-(x+n+i-j)+1)%mod;
		add(dp[i+1][j],(LL)dp[i][j]*coef%mod);
		
		coef=max(0,f[i]-sum[i]-j+1);cur=sum[i]+j+1;
		for(auto v:have[i])
		{
			coef=(LL)coef*max(0,v-cur+1)%mod;
			cur++;
		}
		add(dp[i+1][j+1],(LL)dp[i][j]*coef%mod);
	}
	return dp[n][x];
}

int main()
{
	scanf("%d%d",&n,&mod);
	
	for(int i=0;i<n+n;i++)
	{
		g[i]=n+n-1;
		while(g[i]*g[i]+i*i>n*n*4)g[i]--;
		f[i]=n+n-1;
		while(f[i]&&f[i]*f[i]+i*i>=n*n)f[i]--;
	}
	reverse(f,f+n);reverse(g,g+n);
	
	for(int i=n+n-1;i>=n;i--)
	{
		for(int j=n-1;j>=0;j--)
		{
			if(f[j]>=g[i])sum[j]++;
			else
			{
				have[j].pb(g[i]);
				break;
			}
		}
	}
	
	int ans=0;
	for(int i=0;i<=n;i++)
	{
		if(i&1)ans+=mod-calc(i);
		else ans+=calc(i);
		if(ans>=mod)ans-=mod;
	}
	printf("%d\n",ans);
	return 0;
}