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
//I love Nanami Chiaki
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n;
ll dp[507][257][257];  //i:选到第几个数 j:要选几个上限 k:已经选了几个上限 
ll sx[507],xx[507];
struct ID{
	ll fst;
	int poi;
}id[1007];
bool cmp(ID X,ID Y){
	if (X.fst==Y.fst) return sx[X.poi]<sx[Y.poi];
	return X.fst<Y.fst;
}
int mod;
int main(){
	scanf("%lld%d",&n,&mod);
	for (int i=1;i<=2*n;i++){
		sx[i]=sqrt(4*n*n-(i-1)*(i-1));
		if (sx[i]==2*n) sx[i]--;
		if (i>n){
			id[i].fst=sx[i];id[i].poi=i;
		}
	}
	for (int i=1;i<=n;i++){
		xx[i]=sqrt(n*n-(i-1)*(i-1));
		if (xx[i]*xx[i]==n*n-(i-1)*(i-1)) xx[i]--;
		id[i].fst=xx[i];id[i].poi=i;
	}
	sort(id+1,id+2*n+1,cmp);
	memset(dp,0,sizeof(dp));
	for (int i=0;i<=n;i++){
		dp[0][i][0]=1;
	}
	for (int i=1;i<=2*n;i++){
		int p=id[i].poi;
		if (p>n){
			for (int j=0;j<=n;j++){
				for (int k=0;k<=min(i-1,j);k++){
					if ((sx[p]-(i-k-1)+1)>0) dp[i][j][k]=dp[i][j][k]+1ll*dp[i-1][j][k]*(sx[p]-(i-k-1)+1)%mod;
				}
			}
		}
		else{
			for (int j=0;j<=n;j++){
				for (int k=0;k<=min(i-1,j);k++){
					if ((xx[p]-(i-k-1)+1)>0) dp[i][j][k]=(dp[i][j][k]+1ll*dp[i-1][j][k]*(xx[p]-(i-k-1)+1)%mod)%mod;
					if (k!=j && (sx[p]-(2*n-(j-k))+1)>0) dp[i][j][k+1]=(dp[i][j][k+1]+1ll*dp[i-1][j][k]*(sx[p]-(2*n-(j-k))+1)%mod)%mod;
				}
			}
		}
	}
	ll ans=0;
	for (int i=n;i>=0;i--){
		if ((n-i)&1){
			ans=((ans-dp[2*n][i][i])%mod+mod)%mod;
		}
		else{
			ans=(ans+dp[2*n][i][i])%mod;
		}
	}
	printf("%lld\n",ans);
	return 0;
}