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<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#define pii pair<int,int> 
#define mp make_pair
#define fr first
#define sc second
using namespace std;
int n,P,sl,fh,ans,l[512],r[512],dp[512][256];
pii a[512];
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
void upd(int &x,int y) {x+=y; if(x>=P) x-=P;}
int main()
{
	n=rd();P=rd();
	for(int i=0;i<n<<1;++i)
	{
		r[i]=min(2*n-1,(int)floor(sqrt(4*n*n-i*i)));
		if(i<n) l[i]=ceil(sqrt(n*n-i*i)),a[i]=mp(l[i]-1,-i);
		else a[i]=mp(r[i],-i);
	}
	sort(a,a+n*2);for(int i=0;i<n<<1;++i) a[i].sc=-a[i].sc;
	for(int cnt,k=0;k<=n;++k)
	{
		memset(dp,0,sizeof(dp));cnt=0;dp[0][0]=1;
		for(int i=0;i<n<<1;++i)
		{
			if(a[i].sc<n) cnt++;
			for(int j=0,M=min(k,cnt);j<=M;++j)
				if(a[i].sc<n)
				{
					dp[i+1][j]=1ll*dp[i][j]*(r[a[i].sc]+1-(2*n-1-a[i].sc+k-j))%P;
					if(j) dp[i+1][j]=(dp[i+1][j]+1ll*dp[i][j-1]*(a[i].fr+1-(i-(cnt-j))))%P;
				}
				else dp[i+1][j]=1ll*dp[i][j]*(a[i].fr+1-(i-(cnt-j)))%P;
		}
		if(k&1) upd(ans,P-dp[n<<1][k]); else upd(ans,dp[n<<1][k]);
	}
	printf("%d\n",ans);
	return 0;
}