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
/*Lucky_Glass*/
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=700;
int n,mod,Nf,Ng;
vector< pair<int,int> > Epr;
int Ef[N+3][N+3];

int main(){
	scanf("%d%d",&n,&mod);
	Nf=2*n-1;Ng=2*n-1;
	for(int i=0;i<2*n;i++){
		while(i*i+Nf*Nf>4*n*n && Nf>=0) Nf--;
		while(i*i+Ng*Ng>=n*n && Ng>=0) Ng--;
		if(i>=n) Epr.push_back(make_pair(Nf+1,0));
		else  Epr.push_back(make_pair(Ng+1,Nf+1));
//		printf("%d %d\n",Epr.back().first,Epr.back().second);
	}
	sort(Epr.begin(),Epr.end());
	int Vans=0;long long typ=1;
	for(int k=0;k<=n;k++){
		memset(Ef,0,sizeof Ef);
		Ef[0][0]=1;
		for(int i=0,Ctf=0,Ctg=0;i<(int)Epr.size();Ctg+=Epr[i].second==0,Ctf+=Epr[i].second!=0,i++){
			for(int j=0;j<=k;j++){
				int tmp=Ef[i][j];
				if(Epr[i].second){
					if(j!=k) Ef[i+1][j+1]=(Ef[i+1][j+1]+1ll*tmp*(Epr[i].first-j-Ctg)%mod)%mod;
					Ef[i+1][j]=(Ef[i+1][j]+1ll*tmp*(Epr[i].second-k-n-(Ctf-j))%mod)%mod;
				}
				else
					Ef[i+1][j]=(Ef[i+1][j]+1ll*tmp*(Epr[i].first-j-Ctg)%mod)%mod;
			}
//			printf("%d %d\n",Ctf,Ctg);
		}
//		printf("%d\n",Ef[Epr.size()][k]);
		Vans=(Vans+typ*Ef[Epr.size()][k]+mod)%mod;
		typ*=-1;
	}
	printf("%d\n",Vans);
	return 0;
}
