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 cs const
#define pb push_back
#define fi first
#define se second
using namespace std;
int Mod;
int add(int a, int b){ return a + b >= Mod ? a + b - Mod : a + b; }
int dec(int a, int b){ return a - b < 0 ? a - b + Mod : a - b; }
int mul(int a, int b){ return 1ll * a * b % Mod; }
void Add(int &a, int b){ a = add(a,b); }
void Dec(int &a, int b){ a = dec(a,b); }
void Mul(int &a, int b){ a = mul(a,b); }
cs int N = 505;
typedef pair<int, int> pi;
int n; pi a[N];
int dp[N][N];
int main(){
	#ifdef FSYolanda
	freopen("1.in","r",stdin);
	#endif
	scanf("%d%d",&n,&Mod);
	for(int i=0; i<n; i++)
	a[i] = pi(sqrt(n*n-1-i*i) + 1, sqrt(4*n*n-i*i) + 1);
	for(int i=n; i<n+n; i++)
	a[i] = pi(sqrt(4*n*n-i*i) + 1,0);
	sort(a, a+n+n); int ans = 0;
	for(int k = 0; k <= n; k++){
		memset(dp, 0, sizeof(dp));
		dp[0][0] = 1; 
		for(int i=0,c=0,z=0; i<n+n; i++){
			int p = min(n+n, a[i].fi);
			int q = min(n+n, a[i].se);
			for(int j=0,coe; j<=k; j++)
			if(coe = dp[i][j]){
			if(!q) Add(dp[i+1][j],mul(coe,p-c-j));
			else{
				Add(dp[i+1][j+1],mul(coe,p-c-j));
				Add(dp[i+1][j],mul(coe,q-n-k-z+j));
			} 
			} if(q) ++z; else ++c;
		} if(k & 1) Dec(ans, dp[n+n][k]);
		else Add(ans, dp[n+n][k]);
	} cout << ans; return 0;
}