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<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<bitset>
#include<set>
#define N (1010)
#define M ()
#define inf (0x7f7f7f7f)
#define rg register int
#define Label puts("NAIVE")
#define spa print(' ')
#define ent print('\n')
#define rand() (((rand())<<(15))^(rand()))
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
typedef long double ld;
typedef long long LL;
typedef unsigned long long ull;
using namespace std;
namespace fastIO1{
	inline char read(){
		static const int IN_LEN=1000000;
		static char buf[IN_LEN],*s,*t;
		return (s==t?t=(s=buf)+fread(buf,1,IN_LEN,stdin),(s==t?-1:*s++):*s++);
	}
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=read();!isdigit(c);c=read()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=read())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
	inline char readc(char &c){
		for(c=read();!isalpha(c)&&!isdigit(c);c=read())
		if(c==-1)return 0;
	}
	const int OUT_LEN = 10000000;
	char obuf[OUT_LEN],*ooh=obuf;
	inline void print(char c) {
		if(ooh==obuf+OUT_LEN)fwrite(obuf,1,OUT_LEN,stdout),ooh=obuf;
		*ooh++=c;
	}
	template<class T>
	inline void print(T x){
		static int buf[30],cnt;
		if(x==0)print('0');
		else{
			if(x<0)print('-'),x=-x;
			for(cnt=0;x;x/=10)buf[++cnt]=x%10+48;
			while(cnt)print((char)buf[cnt--]);
		}
	}
	inline void flush(){fwrite(obuf,1,ooh-obuf,stdout);}
}
namespace fastIO2{
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=getchar();!isdigit(c);c=getchar()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=getchar())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
}
using namespace fastIO1;
#define mkp make_pair
int n,P,c[N],f[N],ans;
pair<int,int> a[N];
int getf(int x,int y){
	int ans=0;
	for(;ans<n*2&&ans*ans+y*y<x*x;ans++);
	return ans;
}
int getg(int x,int y){
	int ans=0;
	for(;ans<n*2&&ans*ans+y*y<=x*x;ans++);
	return ans;
}
int main(){
	read(n),read(P);
	for(int i=0;i<n;i++)a[i+1]=mkp(getf(n,i),-i);
	for(int i=n;i<2*n;i++)a[i+1]=mkp(getg(n*2,i),1);
	sort(a+1,a+2*n+1);
//	for(int i=1;i<=2*n;i++)
//	cout<<a[i].first<<" "<<a[i].second<<endl;
//	puts("-------------------");
	for(int i=0;i<n;i++)c[i]=getg(n*2,i);
	for(int k=0;k<=n;k++){
		memset(f,0,sizeof(f));
		f[0]=1; int s1=0,s2=0;
		for(int i=1;i<=2*n;i++)
		if(a[i].second==1){
//			cout<<a[i].first<<" "<<s1<<" faq"<<" "<<i<<endl;
			for(int j=0;j<=s2;j++)
			f[j]=(1ll*f[j]*(a[i].first-s1-j)%P+P)%P;
//			cout<<j<<" "<<f[j]<<" "<<a[i].first-s1-j<<endl;
			s1++;
		}
		else{
			for(int j=s2;j>=0;j--){
				f[j+1]=(0ll+f[j+1]+1ll*f[j]*(a[i].first-s1-j)%P+P)%P;
				f[j]=(1ll*f[j]*(c[-a[i].second]-n-k-s2+j)%P+P)%P;
//				cout<<j<<" "<<f[j]<<" "<<f[j+1]<<" "<<n+k+s2-j<<" "<<c[-a[i].second]<<endl;
			}
			s2++;
		}
//		cout<<k<<" "<<f[k]<<endl;
//		puts("-------");
		if(k&1)(ans+=P-f[k])%=P;else (ans+=f[k])%=P;
	}
	printf("%d\n",ans<0?ans+P:ans);
}