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 clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> pii;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=255*2;
int n,mod;
int Pow(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=(LL)x*x%mod)
		if (y&1)
			ans=(LL)ans*x%mod;
	return ans;
}
void Add(int &x,int y){
	if ((x+=y)>=mod)
		x-=mod;
}
void Del(int &x,int y){
	if ((x-=y)<0)
		x+=mod;
}
int Add(int x){
	return x>=mod?x-mod:x;
}
int Del(int x){
	return x<0?x+mod:x;
}
int f[N],g[N];
int dp[N][N][N];
pair <int,int> p[N];
bool cmp(pair <int,int> a,pair <int,int> b){
	if (a.fi!=b.fi)
		return a.fi<b.fi;
	return a.se>b.se;
}
int main(){
	n=read(),mod=read();
	For(i,0,n-1)
		while (i*i+f[i]*f[i]<n*n)
			f[i]++;
	For(i,0,n*2-1)
		while (g[i]<n*2&&i*i+g[i]*g[i]<=n*n*4)
			g[i]++;
	For(i,1,n)
		p[i]=mp(f[i-1],i-1);
	For(i,1,n)
		p[i+n]=mp(g[i+n-1],i+n-1);
	sort(p+1,p+n*2+1,cmp);
//	outarr(f,0,n-1);outarr(g,0,n*2-1);
//	For(i,1,n*2)
//		printf("p[%d] = (%d,%d)\n",i,p[i].fi,p[i].se);
	For(i,0,n)
		dp[0][0][i]=1;
	For(i,0,n*2)
		For(j,0,i)
			For(k,0,n){
				int v=dp[i][j][k];
				if (!v)
					continue;
//				printf("dp[%d][%d][%d] = %d\n",i,j,k,v);
				int nv=p[i+1].fi,id=p[i+1].se;
				if (id<n){
					if (k)
						Del(dp[i+1][j+1][k-1],(LL)v*max(0,nv-j)%mod);
					Add(dp[i+1][j][k],(LL)v*max(0,g[id]-k-n-(n-id-1))%mod);
				}
				else {
					Add(dp[i+1][j+1][k],(LL)v*max(0,nv-j)%mod);
				}
			}
	int ans=0;
	For(i,0,n*2)
		Add(ans,dp[n*2][i][0]);
	cout<<ans<<endl;
	return 0;
}