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<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
int Mod;

int n;
int dp[512][256][256];
int L[512],R[512];
struct Rec{
	int id,u,v;
}rec[512]; int m;
bool operator<(Rec x,Rec y){return x.u<y.u||x.u==y.u&&x.v<y.v;}
inline void add(int &x,int y){x=(x+y)%Mod;}
inline void add(int &x,ll y){x=(x+y)%Mod;}
int main()
{
	//freopen("data.in","r",stdin);
	//freopen("A.out","w",stdout);

	scanf("%d%d",&n,&Mod);
	for (int i=0;i<n;i++) L[i]=ceil(sqrt(n*n-i*i)),R[i]=min(floor(sqrt(4*n*n-i*i)),2.0*n-1),rec[++m]=(Rec){i,L[i]-1,R[i]};
	for (int i=n;i<n+n;i++) L[i]=0,R[i]=min(floor(sqrt(4*n*n-i*i)),2.0*n-1),rec[++m]=(Rec){i,R[i],0};
	//for (int i=0;i<m;i++) printf("%d: L %d R %d\n",i,L[i],R[i]);
	sort(rec+1,rec+m+1);
	for (int i=0;i<=n;i++) dp[0][0][i]=1;
	for (int i=0;i<m;i++){
		for (int j=0;j<=i&&j<=n;j++)
			for (int k=0;k+j<=n;k++){
				if (!dp[i][j][k]) continue;
				int x=rec[i+1].id;
				if (x>=n){
					if (R[x]+1-i+j>0) add(dp[i+1][j][k],1LL*dp[i][j][k]*(R[x]+1-i+j));
					continue;
				}
				if (L[x]-i+j>0) add(dp[i+1][j][k],-1LL*dp[i][j][k]*(L[x]-i+j));
				if (k){
					if (R[x]+1-m+k>0) add(dp[i+1][j+1][k-1],1LL*dp[i][j][k]*(R[x]+1-m+k));
				}
			}
	}
	int ans=0;
	for (int i=0;i<=n;i++) add(ans,dp[m][i][0]);
	printf("%d\n",(ans+Mod)%Mod);
	return 0;
}