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<bits/stdc++.h>
using namespace std;
int a[505],b[505],n,MOD;
vector<pair<pair<int,int>,int> > s;
int f[505][505];
int solve(int tp){
//	if(tp!=10) return 0;
	memset(f,0,sizeof(f));
	f[0][0]=1;
	for(int i=1;i<=s.size();++i){
		int pos=s[i-1].second;
		for(int x=0;x<=n+n;++x){
			if(pos<n){
				if(x>0){
					f[i][x]=(f[i][x]+1ll*f[i-1][x-1]
						*max(0,b[pos]-(tp+x-1)))%MOD;
//					if(f[i][x]!=0) printf("<%d>",max(0,b[pos]-(tp+x-1)));
				}
				if(i-x>0){
					f[i][x]=(f[i][x]+MOD-1ll*f[i-1][x]
						*max(0,a[pos]-(i-x-1))%MOD)%MOD;
				}
			}else{
				if(i-x>0){
					f[i][x]=(f[i][x]+1ll*f[i-1][x]
						*max(0,b[pos]-(i-x-1)))%MOD;
//					if(f[i][x]!=0) printf("<%d>",max(0,b[pos]-(i-x-1)));
				}
			}
//			if(tp==10&&f[i][x]!=0) printf("(%d %d %d)",i,x,f[i][x]);
		}
	}
	return f[(int)s.size()][n+n-tp];
}
int main(){
	scanf("%d%d",&n,&MOD);
	for(int i=0;i<n+n;++i){
		a[i]=1e9,b[i]=-1e9;
		for(int j=0;j<n+n;++j)
			if(i*i+j*j>=n*n&&i*i+j*j<=(n+n)*(n+n)){
				a[i]=min(a[i],j);
				b[i]=max(b[i],j+1);
			}
//		printf("<%d %d>",a[i],b[i]);
		if(i<n) s.push_back(make_pair(make_pair(a[i],b[i]),i));
		else s.push_back(make_pair(make_pair(b[i],a[i]),i));
	}
	sort(s.begin(),s.end());
//	for(auto x:s) printf("(%d %d)",x.first,x.second);
	int ans=0;
	for(int x=n;x<=n+n;++x){
		int key=solve(x);
		ans=(ans+key)%MOD;
/*		if(key!=0){
			printf("|%d %d|",x,key);
		}
*/	}
	printf("%d\n",ans);
	return 0;
}