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 <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<ctime>
#include<set>
#include<queue>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);++(i))
#define fd1(i,n) for ((i)=(n);(i)>=1;--(i))
#define fz0g(i,n) for ((i)=0;(i)<=(n);++(i))
#define fd0g(i,n) for ((i)=(n);(i)>=0;--(i))
#define fz0k(i,n) for ((i)=0;(i)<(n);++(i))
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;--(i))
#define fz(i,x,y) for ((i)=(x);(i)<=(y);++(i))
#define fd(i,y,x) for ((i)=(y);(i)>=(x);--(i))
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
using namespace std;
int n,mod,i,j,k,dp[505][505],ans,lb[505],rb[505];
pair<int,int> seq[505];
void inc(int &x,int y)
{
	x+=y;if(x>=mod) x-=mod;
}
void dec(int &x,int y)
{
	x-=y;if(x<0) x+=mod;
}
bool cmp(pair<int,int> x,pair<int,int> y)
{
	if(x.first!=y.first) return x.first<y.first;
	return x.second>y.second; 
}
int solve(int x)
{
	int i,j,cl=0,cr=0;
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	fz1(i,n+n){
		if(seq[i].second>n){
			fz0g(j,x){
				dp[i][j]=1ll*dp[i-1][j]*(seq[i].first-(j+cr))%mod;
			}
			cr++;
		}
		else{
			fd0g(j,x){
				inc(dp[i][j+1],1ll*dp[i-1][j]*(seq[i].first-(j+cr))%mod);
				dp[i][j]=1ll*dp[i-1][j]*(rb[seq[i].second]-(n+x+(cl-j)))%mod;
			}
			cl++;
		}
//		cerr<<dp[i][0]<<endl;
	}
	return dp[n+n][x]; 
}
int main()
{
	scanf("%d%d",&n,&mod);
	fz1(i,n){
		while(lb[i]<n*2&&(i-1)*(i-1)+lb[i]*lb[i]<n*n) lb[i]++;
	}
	fz1(i,n+n){
		while(rb[i]<n*2&&(i-1)*(i-1)+rb[i]*rb[i]<=n*n*4) rb[i]++;
	}
	fz1(i,n){
		seq[i]=make_pair(lb[i],i);
	}
	fz1(i,n){
		seq[i+n]=make_pair(rb[i+n],i+n);
	}
	sort(seq+1,seq+n+n+1,cmp);
	fz0g(i,n){
		int t=solve(i);
		if(i&1) dec(ans,t); else inc(ans,t);
	}
	cout<<ans<<endl;
	return 0;
}
