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<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 505
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
const int n=read(),mod=read();
int dp[N][N>>1],ans;
pair<int,int> p[N];
int getF(int x){
	int tmp=2*n-1;
	while(x*x+tmp*tmp>4*n*n)--tmp;
	return tmp+1;
}
int getG(int x){
	int tmp=2*n-1;
	while(x*x+tmp*tmp>=n*n)--tmp;
	return tmp+1;
}
int main(){
	for(int i=0;i<(n<<1);++i){
		if(i<n)p[i]=make_pair(getG(i),getF(i));
		else p[i]=make_pair(getF(i),0);
	}
	sort(p,p+(n<<1));
	for(int k=0;k<=n;++k){
		memset(dp,0,sizeof(dp));
		dp[0][0]=1;
		int c1=0,c2=0;
		for(int i=0;i<(n<<1);++i){
			if(!p[i].second){
				for(int j=0;j<=k;++j){
					dp[i+1][j]=(dp[i+1][j]+1LL*dp[i][j]*(p[i].first-j-c1))%mod;
				}
				++c1;
			}
			else{
				for(int j=0;j<=k;++j){
					dp[i+1][j]=(dp[i+1][j]+1LL*dp[i][j]*(p[i].second-k-n-(c2-j)))%mod;
					dp[i+1][j+1]=(dp[i+1][j+1]+1LL*dp[i][j]*(p[i].first-c1-j))%mod;	
				}
				++c2;
			}
		}	
		ans=(ans+(k&1?-1:1)*dp[n<<1][k])%mod;
	}
	printf("%d\n",(ans+mod)%mod);
	return 0;
}
