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<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
#define LL long long
#define LD long double
using namespace std;
const int NN=400 +117;
const int MM=200 +117;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
void open(){
	freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
}
void close(){
	fclose(stdin);
	fclose(stdout);
}


int m,n;
int mod;
struct node{
	int l,r;
	int id;
	int v(){
		if(l==-1)return r;
		else return l;
	}
}a[NN];
bool cmp(node a,node b){
	if((a.id<n&&b.id<n)||(a.id>=n&&b.id>=n)){
		return a.id>b.id;
	}
	else return a.v()==b.v()?a.id>b.id:a.v()<b.v();
}
LL dp[2][NN]={};
LL v(LL x){
	return max(x,0ll);
}
LL calc(int x){
	for(int i=0;i<=n+1;++i)dp[0][i]=0;
	dp[0][0]=1;
	int now=0;
	int pre=0;
	for(int i=0;i<2*n;++i){
		now^=1;
		for(int j=0;j<=pre+1;++j)dp[now][j]=0;
		if(a[i].l==-1){
			for(int j=0;j<=pre;++j){
				dp[now][j]=dp[now^1][j]*v(1+a[i].r-j-i+pre)%mod;
			}
		}
		else{
			for(int j=0;j<=pre;++j){
				dp[now][j]+=dp[now^1][j]*v(1+a[i].r-(n+pre+x-j));
				dp[now][j]%=mod;
				dp[now][j+1]+=dp[now^1][j]*v(1+a[i].l-j-i+pre);
				dp[now][j+1]%=mod;
			}
			++pre;
		}
	}
	return dp[now][x];
}
int main(){
	//open();
	n=read();
	mod=read();
	for(int i=0;i<2*n;++i){
		a[i].r=min(2*n-1,(int)sqrt(4*n*n-i*i));
		a[i].id=i;
		if(i>=n)a[i].l=-1;
		else a[i].l=sqrt(n*n-i*i-1);
	}
	sort(a,a+2*n,cmp);
	LL ans=0;
	for(int i=0,sym=1;i<=n;++i,sym=-sym){
		ans+=sym*calc(i);
		ans%=mod;
	}
	ans=(ans+mod)%mod;
	printf("%lld\n",ans);
	close();
	return 0;
}