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;

typedef long long lint;
typedef pair<int,int> pii;
typedef long double louble;

#define fi first
#define se second

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 503;

int mo;

template<typename T1,typename T2> inline T1 ad(T1 &a,T2 b){return a=a+b>=mo?a+b-mo:a+b;}
template<typename T1,typename T2> inline T1 dl(T1 &a,T2 b){return a=a>=b?a-b:a-b+mo;}

int n,nn;pii p[_];
lint f[_][_]={0};

inline int lbound(int i){int x=nn-1;while(x>=0 && x*x+i*i>=n*n)x--;return x+1;}
inline int rbound(int i){int x=nn-1;while(x>=0 && x*x+i*i>nn*nn)x--;return x+1;}

int main()
{
	n=ty(),mo=ty(),nn=n+n;

	for(int i=0;i<nn;i++){if(i<n)p[i]=pii(lbound(i),rbound(i));else p[i]=pii(rbound(i),-1);}

	sort(p,p+nn);
	
	lint ans=0;
	for(int k=0;k<=n;k++)
	{
		memset(f,0,sizeof(f)),f[0][0]=1;
		int cf=0,cs=0;
		for(int i=0;i<nn;i++)
		{
			for(int j=0;j<=k;j++)
			{
				if(p[i].se<0)ad(f[i+1][j],f[i][j]*(p[i].fi-cs-j)%mo);
				else
				{
					if(j<k)ad(f[i+1][j+1],f[i][j]*(p[i].fi-cs-j)%mo);
					ad(f[i+1][j],f[i][j]*(p[i].se-n-k-cf+j)%mo);
				}
			}
			if(p[i].se<0)cs++;else cf++;
		}
		ad(ans,f[nn][k]*(k&1?mo-1:1)%mo);
	}

	printf("%lld\n",ans);
	
	return 0;
}
