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>
#define N 260
#define ll long long
#define For(i,x,y) for(int i=(x);i<=(y);++i)
#define Rof(i,x,y) for(int i=(x);i>=(y);--i)
#define mset(x,y) memset(x,y,sizeof(x))
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
using namespace std;
int cnt,n,mod;
struct qwq{ int val,id; }a[N*2];
ll f[N*2][N];
int g[N];
bool cmp(const qwq &x,const qwq &y){ return x.val==y.val?x.id>y.id:x.val<y.val; }
ll solve(int k){
	mset(f,0);int tmp=0;
	f[0][0]=1;
	For(i,1,cnt){
		if(a[i].id>=n) tmp++;
		For(j,0,i-tmp){
			if(a[i].id>=n) f[i][j]=f[i-1][j]*(1ll*a[i].val-(j+tmp-2)+mod)%mod;
			else{
				if(j!=i-tmp) (f[i][j]+=f[i-1][j]*(1ll*g[a[i].id]-(n+k-1+(i-1-tmp-j))+mod)%mod)%=mod;
				if(j) (f[i][j]+=f[i-1][j-1]*(1ll*a[i].val-(j-1+tmp-1)+mod)%mod)%=mod;
			}
		}
	}
	return f[cnt][k];
}
int main(){
	ll ans=0;
	scanf("%d%d",&n,&mod);
	For(i,0,n-1){
		a[++cnt]=(qwq){(int)sqrt(n*n-1-i*i),i};
		g[i]=(int)sqrt(4*n*n-i*i);
		g[i]=min(g[i],2*n-1);
	}
	For(i,n,2*n-1)
		a[++cnt]=(qwq){(int)sqrt(4*n*n-i*i),i};
	sort(a+1,a+cnt+1,cmp);
	For(i,0,n){
		if(i&1) (ans+=mod-solve(i))%=mod;
		else (ans+=solve(i))%=mod;
	}
	printf("%lld\n",ans);
}