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
/****************************************************************
*	Author: huhao
*	Email: 826538400@qq.com
*	Create time: 2020-03-22 14:10:15
****************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
#define i64 long long
#define pii std::pair<i64,i64>
const int N=510;
i64 n,l[N],r[N],mod;
i64 ans,f[N],F[N],s[N];
pii a[N];
i64 &Add(i64 &a,i64 b){ return a=(a+b%mod+mod)%mod; }
int main()
{
	n=read(); mod=read();
	fr(i,0,n*2-1)
	{
		l[i]=n*2;
		fr(j,0,n*2-1) if(i*i+j*j<=4*n*n&&i*i+j*j>=n*n)
		{
			l[i]=std::min(l[i],1ll*j); r[i]=std::max(r[i],1ll*j);
		}
		if(l[i]==0) a[i]=pii(r[i],0);
		else a[i]=pii(l[i]-1,r[i]);
	}
	std::sort(a,a+n*2);
	fr(i,0,n*2) s[i]=(i?s[i-1]:0)+(a[i].second==0);
//	fr(i,0,n*2-1) printf("%d %d\n",int(l[i]),int(r[i]));
	fr(i,0,n*2)
	{
		memset(f,0,sizeof(f)); f[0]=1;
		fr(j,0,n*2-1)
		{
			fr(k,0,i){ F[k]=f[k]; f[k]=0; }
			fr(k,0,i)
				if(a[j].second)
				{
					Add(f[k],F[k]*(a[j].second+1-(j-1)-(s[n*2]-s[j])-(i-k))); Add(f[k+1],F[k]*(a[j].first+1-s[j-1]-k));
				}
				else Add(f[k],F[k]*(a[j].first+1-s[j-1]-k));
		}
		Add(ans,(i&1?-1:1)*f[i]);
	}
	printf("%d\n",int(ans));
	return 0;
}