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;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define poly vector<ll>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
inline char gc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x=0;char ch=gc();bool positive=1;
	for(;!isdigit(ch);ch=gc()) if(ch=='-') positive=0;
	for(;isdigit(ch);ch=gc()) x=x*10+ch-'0';
	return positive?x:-x;
}
inline void write(ll x){
	if(x<0){
		x=-x;putchar('-');
	}
	if(x>=10) write(x/10);
	putchar('0'+x%10);
}
inline void writeln(ll x){write(x);puts("");}
inline void writep(ll x){write(x);putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=505;
int f[N][N];
struct info{
	int l,r;
}a[N];
bool cmp(info x,info y){
	return x.l==y.l?x.r<y.r:x.l<y.l;
}
int main(){
	int m=read(),mo=read(),n=0;
	For(i,0,2*m-1){
		int L=0,R=0;
		for(int j=2*m-1;j>=0&&j*j+i*i>=m*m;j--) L=j;
		for(int j=0;j<=2*m-1&&j*j+i*i<=4*m*m;j++) R=j;
		R++;
		if(L==0) swap(L,R);
		a[++n]=(info){L,R};
	}
	sort(a+1,a+n+1,cmp);
	// For(i,0,n-1) cout<<a[i].l<<" "<<a[i].r<<endl;
	int ans=0;
	For(k,0,m){
		memset(f,0,sizeof(f));
		f[0][0]=1;
		int cnt1=0,cnt2=0;
		For(i,1,n){
			For(j,0,k) if(f[i-1][j]){
				if(a[i].r==0){
					f[i][j]=(f[i][j]+(ll)f[i-1][j]*(a[i].l-j-cnt1))%mo;
				}else{
					if(j<k) f[i][j+1]=(f[i][j+1]+(ll)f[i-1][j]*(a[i].l-j-cnt1))%mo;
					f[i][j]=(f[i][j]+(ll)f[i-1][j]*(a[i].r-m-k-(cnt2-j)))%mo;
				}
			}
			if(a[i].r==0) cnt1++;
			else cnt2++;
		}
		if(k%2) ans=(ans+mo-f[n][k])%mo;
		else ans=(ans+f[n][k])%mo;
	}
	cout<<ans;
}