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;
template<typename T>inline T read(){
	T f=0,x=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
#define int long long
namespace run{
	const int N=509;
	int mod;
	inline int add(int x,int y){return x+y>=mod?x-mod+y:x+y;}
	inline int sub(int x,int y){return x>=y?x-y:x+mod-y;}
	inline int qpow(int x,int y){
		int ret=1;
		while(y){
			if(y&1) ret=1LL*x*ret%mod;
			x=1LL*x*x%mod,y>>=1;
		}
		return ret;
	}

	struct Limit{
		int l,r,val,id;explicit Limit(){}
		Limit(int _l,int _r,int _val,int _id):l(_l),r(_r),val(_val),id(_id){}
		inline bool operator <(const Limit &A)const{
			if(A.val!=val) return val<A.val;
			return r<A.r;
		}
	}d[N];
	int n,f[2][N][N];
	int main(){
		n=read<int>(),mod=read<int>();
		for(int i=0;i<2*n;i++){
			if(i<=n) d[i].l=ceil(sqrt(n*n-i*i));
			else d[i].l=0;
			d[i].r=min(2*n-1,(int)sqrt(4*n*n-i*i));
			if(i<n) d[i].val=d[i].l-1;
			else d[i].val=d[i].r;
			d[i].id=i;
		}
		sort(d,d+2*n);

		int cur=0;
		for(int k=0;k<=n;k++) f[cur][k][0]=1;
		for(int i=1,t=0;i<=2*n;i++){
			int pre=cur;cur^=1;
			for(int k=0;k<=n;k++)
				for(int j=k;j>=0;j--){
					if(d[i-1].id>=n) f[cur][k][j]=1LL*f[pre][k][j]*(d[i-1].r+1-(t+j))%mod;
					else{
						f[cur][k][j]=1LL*f[pre][k][j]*(d[i-1].r+1-(2*n-d[i-1].id-1+k-j))%mod;
						if(j) f[cur][k][j]=(1LL*f[pre][k][j-1]*(d[i-1].l-(t+j-1))+f[cur][k][j])%mod;
					}
				}
			if(!d[i-1].l) t++;
		}
		int ans=0;
		for(int k=0;k<=n;k++)
			if(k&1) ans=sub(ans,f[cur][k][k]);
			else ans=add(ans,f[cur][k][k]);
		printf("%lld\n",ans);
		return 0;
	}
}
#undef int
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}