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 For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 255; 
int n,mod,ans,l[N*2],r[N*2],f[N][N][N];

inline int Mod(int x){
	return x>=mod?x-mod:x;
}

int main(){
	n=read(),mod=read();
	For(i,1,2*n){
		int x=max(0,n*n-(i-1)*(i-1)),y=4*n*n-(i-1)*(i-1);
		l[i]=ceil(sqrt(x)),r[i]=min(int(sqrt(y)),2*n-1);
	}
	For(i,0,n) f[n+1][0][i]=1;
	int las=2*n+1;
	Dow(i,n+1,2){
		For(j,0,n-i+1){
			int x=1,p=las;
			while (r[p-1]<l[i-1]) --p,x=1ll*x*(r[p]+1-(2*n-p+j))%mod;
			f[i-1][j][j]=(f[i-1][j][j]+1ll*f[i][j][j]*x%mod*(r[i-1]+1-(n+j+(n-i+1-j))))%mod;
			For(k,j+1,n){
				f[i-1][j+1][k]=(f[i-1][j+1][k]+1ll*f[i][j][k]*(l[i-1]-1-(j+2*n-p))%mod*x)%mod;
				f[i-1][j][k]=(f[i-1][j][k]+1ll*f[i][j][k]*(r[i-1]+1-(n+k+(n-i+1-j)))%mod*x)%mod;
			}
		}
		while (r[las-1]<l[i-1]) --las;
	}
	For(i,0,n){
		int x=1;
		FOR(j,n+1,las) x=1ll*x*(r[j]+1-(i+(2*n-j)))%mod;
		if (i&1) ans=(ans+1ll*(mod-f[1][i][i])*x)%mod;
			else ans=(ans+1ll*f[1][i][i]*x)%mod;
	}
	printf("%d\n",(ans+mod)%mod);
}
