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<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ
long long M;
long long dp[600][300];
pair<int,int>p[600];
int main(){
	int a;
	scanf("%d%lld",&a,&M);
	for(int i=0;i<a*2;i++){
		if(i<a){
			p[i]=make_pair(a*a-i*i-1,i);
		}else{
			p[i]=make_pair(a*a*4-i*i,i);
		}
	}
	std::sort(p,p+a*2);
	long long ret=0;
	for(int i=0;i<=a;i++){
		for(int j=0;j<=a*2;j++)for(int k=0;k<=a;k++)dp[j][k]=0;
		dp[0][0]=1;
		int A=0;
		for(int j=0;j<a*2;j++){
			for(int k=0;k<=i;k++){
				if(!dp[j][k])continue;
				int I=p[j].second;
			//	printf("%d %d %d: %lld\n",i,I,k,dp[j][k]);
				if(I<a){

					int LIM1=sqrt(a*a-I*I-0.001)+1;
					int LIM2=min(a*2,(int)sqrt(a*a*4-I*I+0.5)+1);
					dp[j+1][k+1]=(dp[j+1][k+1]+dp[j][k]*(LIM1-j+A-k))%M;
					dp[j+1][k]=(dp[j+1][k]+dp[j][k]*(LIM2-(a+A-k+i)))%M;
					
				}else{
					int LIM=min(a*2,(int)sqrt(a*a*4-I*I+0.5)+1);
					dp[j+1][k]=(dp[j+1][k]+dp[j][k]*(LIM-j+A-k))%M;
				}
			}
			if(p[j].second<a){
				A++;
			}
		}
		if(i%2)ret=(ret+M-dp[a*2][i])%M;
		else ret=(ret+dp[a*2][i])%M;
	}
	printf("%lld\n",ret);
}