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
#pragma GCC optimize("Ofast")
//没错，我就是抄zyy代码了
//啊，代码都不能抄，那还有什么可以抄啊 
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define fi first
#define se second
#define lowbit(x) ((x)&-(x))
#define debug(x) cout << #x " = " << x << endl;
namespace IO{
	const int L = 1 << 15;
	char ibuf[L|1],*iS=ibuf,*iT=ibuf;
	char obuf[L|1],*oS=obuf,*oT=obuf+L;
	char c,st[66];int tp=0,f;
	inline char gc(){
		if(iS==iT) iT=(iS=ibuf)+fread(ibuf,sizeof(char),L,stdin);
		return (*iS++);
	}
	inline void flush() {
		fwrite(obuf,sizeof(char),oS-obuf,stdout);
		oS = obuf;
	}
	inline void pc(char c){*oS++=c;if(oS==oT) flush();}
	#define gc getchar
	#define pc putchar
	inline ll read(){
		ll x=0;f=1,c=gc();
		for(;!isdigit(c);c=gc())if(c=='-')f=-1;
		for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c&15);
		return x*f;
	}
	void write(ll x){
		if(!x) pc('0');if(x<0) pc('-'),x=-x;
		while(x) st[++tp]=x%10+'0',x/=10;
		while(tp) pc(st[tp--]);
	}
	void wri(ll x){write(x);pc(' ');}
	void writeln(ll x){write(x);pc('\n');}
	struct IOflusher{~IOflusher(){flush();}}_ioflusher_;
}
using IO::read;
using IO::writeln;
using IO::wri;
inline void gg(string s){cout << s << endl;exit(0);}
inline void gg(ll x){writeln(x);exit(0);}
const int N=505;
int n,mod,f[N][N],ans;
pair<int,int>a[N];
#define sqr(x) ((x)*(x))
int main(){
	n = read();mod = read();
	rep(i,0,n){
		while(sqr(i)+sqr(a[i].fi)<sqr(n)) ++a[i].fi;
		--a[i].fi,a[i].se=n+n-1;
		while(sqr(i)+sqr(a[i].se)>sqr(n+n)) --a[i].se;
	}
	rep(i,n,2*n){
		a[i].fi=n+n-1;
		while(sqr(i)+sqr(a[i].fi)>sqr(n+n))--a[i].fi;
	}
	sort(a,a+n+n);
	Rep(t,0,n){
		f[0][0]=1;
		for(int i=0,s1=0,s2=0;i<n+n;++i)
			if(!a[i].se){
				Rep(j,0,t)
					f[i+1][j]=1ll*f[i][j]*(a[i].first+1-(s1+j))%mod;
				++s1;
			}else{
				Rep(j,0,t)
					f[i+1][j]=1ll*f[i][j]*(a[i].second+1-(n+s2+t-j))%mod;
				rep(j,0,t)
					f[i+1][j+1]=(f[i+1][j+1]+1ll*f[i][j]*(a[i].first+1-(s1+j)))%mod;
				++s2;
			}
		ans=(ans+(t&1?mod-f[n+n][t]:f[n+n][t]))%mod;
	}
	writeln(ans);
	return 0;
}