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;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=255;
ll dp[N<<1][N],an;
PI a[N<<1];
int main(){
	int n=read(); const int mod=read();
	For(i,0,2*n-1){
		int l=0; while(l*l+i*i<n*n)l++;
		int r=sqrt(4*n*n-i*i); if(r==2*n)r--;
		a[i]=i<n?mp(l-1,r):mp(r,l); //cout<<l<<" "<<r<<endl;
	}
	sort(a,a+2*n);
	For(o,0,n){
		memset(dp,0,sizeof(dp));
		dp[0][0]=1;
		int sum=0; 
		For(i,0,2*n-1)if(a[i].se){
			For(j,0,o)if(dp[i][j]){
				dp[i][j]%=mod;
				int rk=n+n-((n-sum)-(o-j)); //if(o==0)cout<<rk<<" fjzzq"<<" "<<a[i].se+1-rk<<" "<<endl;
				dp[i+1][j]+=dp[i][j]*(a[i].se+1-rk);
				rk=j+i-sum;
				dp[i+1][j+1]+=dp[i][j]*(a[i].fi+1-rk);
			}
			sum++;
		}else{
			For(j,0,o)if(dp[i][j]){
				dp[i][j]%=mod;
				int rk=j+(i-sum); //if(o==0)cout<<rk<<" "<<j<<" "<<a[i].fi+1-rk<<endl;
				dp[i+1][j]+=dp[i][j]*(a[i].fi+1-rk);
			}
		}
		//cout<<o<<" "<<dp[n*2][o]<<endl;
		an=(an+(o%2?-dp[2*n][o]:dp[2*n][o]))%mod;
	}
	cout<<(an+mod)%mod<<endl;
}