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
//problem:
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mk make_pair
#define lob lower_bound
#define upb upper_bound
#define fst first
#define scd second

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

inline int read(){
	int f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline ll readll(){
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=255;
int n,cnt,b[MAXN*2],dp[MAXN*3][MAXN*3],MOD;
pair<int,int>a[MAXN*3];
inline int f(int i){return (int)(sqrt(n*n-i*i-1))+1;}
inline int g(int i){return min(2*n,(int)(sqrt(4*n*n-i*i))+1);}
inline int mod1(int x){return x<MOD?x:x-MOD;}
inline int mod2(int x){return x<0?x+MOD:x;}
int main() {
	n=read();MOD=read();
	for(int i=0;i<n;++i)a[++cnt]=mk(f(i),1);//a
	for(int i=0;i<n;++i)a[++cnt]=mk(g(i),2);//b
	for(int i=n;i<2*n;++i)a[++cnt]=mk(g(i),3);//c
	sort(a+1,a+cnt+1);
	int pos=2*n;
	for(int i=1;i<=2*n;++i)if(a[i].scd==1)b[i]=++pos;
	assert(pos==3*n);
	int ans=0;
	for(int k=0;k<=n;++k){
		for(int i=1;i<=2*n;++i)for(int j=1;j<=k;++j)dp[i][j]=0;
		dp[0][0]=1;
		int c=0;
		for(int i=1;i<=2*n;++i){
			if(a[i].scd==1){
				for(int j=0;j<=k;++j){
					dp[i][j]=(ll)dp[i-1][j]*mod2(a[b[i]].fst%MOD-(n+i-1-c-j+k)%MOD)%MOD;
					if(j)dp[i][j]=mod1(dp[i][j]+(ll)dp[i-1][j-1]*mod2(a[i].fst%MOD-(j-1+c))%MOD);
				}
			}else{
				for(int j=0;j<=k;++j)dp[i][j]=(ll)dp[i-1][j]*mod2(a[i].fst%MOD-(j+c))%MOD;
				++c;
			}
		}
		if(k&1)ans=mod2(ans-dp[2*n][k]);
		else ans=mod1(ans+dp[2*n][k]);
	}
	cout<<ans<<endl;
	return 0;
}