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<cstdio>
#include<utility>
#include<cstring>
#include<algorithm>
#define RI register int
#define CI const int&
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef pair <int,int> pi;
const int N=1005;
int n,mod,f[N],c[N],cnt,ans; pi t[N];
inline void inc(int& x,CI y)
{
	if ((x+=y)>=mod) x-=mod;
}
inline int Mod(int x)
{
	while (x>=mod) x-=mod; while (x<0) x+=mod; return x;
}
inline int F(CI x)
{
	int y=0; while (y<(n<<1)&&x*x+y*y<n*n) ++y; return y;
}
inline int G(CI x)
{
	int y=0; while (y<(n<<1)&&x*x+y*y<=(n<<1)*(n<<1)) ++y; return y;
}
int main()
{
	RI i,j,k; scanf("%d%d",&n,&mod);
	for (i=0;i<n;++i) t[++cnt]=mp(F(i),-i);
	for (i=n;i<(n<<1);++i) t[++cnt]=mp(G(i),1);
	for (i=0;i<n;++i) c[i]=G(i); sort(t+1,t+cnt+1);
	//for (i=1;i<=cnt;++i) printf("%d%c",t[i]," \n"[i==cnt]);
	for (k=0;k<=n;++k)
	{
		memset(f,0,(k+1)<<2); f[0]=1; int s1=0,s2=0;
		for (i=1;i<=cnt;++i) if (t[i].se==1)
		{
			for (j=0;j<=s2;++j) f[j]=1LL*f[j]*Mod(t[i].fi-s1-j)%mod; ++s1;
		} else
		{
			for (j=s2;~j;--j) inc(f[j+1],1LL*f[j]*Mod(t[i].fi-s1-j)%mod),
			f[j]=1LL*f[j]*Mod(c[-t[i].se]-(n+k+s2-j))%mod; ++s2;
		}
		//printf("%d %d\n",k,f[k]);
		if (k&1) inc(ans,Mod(-f[k])); else inc(ans,f[k]);
	}
	return printf("%d",ans),0;
}