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 ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=605;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
int n,Mod,N,F[2][MAXN],ans;pint o[MAXN];
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),Mod=read();
	Rep(i,0,n-1){
		int r1=0,r2;for(;r1*r1+i*i<n*n;r1++);
		for(r2=r1;r2<2*n-1&&(r2+1)*(r2+1)+i*i<=4*n*n;r2++);
		o[++N]=mk(r1,r2+1);
	}Rep(i,n,2*n-1){
		int r=0;for(;r<2*n-1&&(r+1)*(r+1)+i*i<=4*n*n;r++);
		o[++N]=mk(r+1,0);
	}sort(o+1,o+N+1);
	Rep(i,0,n){
		int now=0,s1=0,s2=0;memset(F[now],0,sizeof(F[now])),F[now][0]=1;
		Rep(j,1,N){
			now^=1,memset(F[now],0,sizeof(F[now]));
			if(!o[j].sec){
				int mx=min(i,s1),u=o[j].fir-s2;
				Rep(k,0,mx)if(F[now^1][k])F[now][k]=1ll*F[now^1][k]*(u-k)%Mod;
				s2++;
			}else{
				int mx=min(i,s1),u=o[j].fir-s2,v=o[j].sec-i-n-s1;
				Rep(k,0,mx)if(F[now^1][k])F[now][k+1]=(F[now][k+1]+1ll*F[now^1][k]*(u-k))%Mod,F[now][k]=(F[now][k]+1ll*F[now^1][k]*(v+k))%Mod;
				s1++;
			}
		}ans=(ans+1ll*(i&1?Mod-1:1)*F[now][i])%Mod;
	}cout<<ans<<"\n";
	return 0;
}


