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 pair<ll,ll> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
//#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int n;
ll mod,dp[505][255];
int a[505],b[505];
vector<P>vec;
int main(){
	cin >> n >> mod;
	for(int i=0;i<n;i++){
		for(int j=0;j<2*n;j++){
			if(i*i+j*j < n*n) a[i]++;
			if(i*i+j*j <= 4*n*n) b[i]++;
		}
		vec.pb(mp(a[i],0));
	}
	for(int i=n;i<2*n;i++){
		for(int j=0;j<2*n;j++){
			if(i*i+j*j <= 4*n*n) b[i]++;
		}
		vec.pb(mp(b[i],1));
	}
	SORT(vec);
	ll ans = 0;
	for(int numm=0;numm<=n;numm++){
		rep(i,505)rep(j,255) dp[i][j] = 0;
		dp[0][0] = 1;
        int one = 0;
	    int cur = n-1;
		for(int i=0;i<vec.size();i++){
			int num = vec[i].fi;
			int ty = vec[i].sc;
			for(int j=0;j<=numm;j++){
				if(dp[i][j] == 0) continue;
				if(ty == 1){
					if(num-j-one >= 1){
						dp[i+1][j] += dp[i][j] * (num-j-one) % mod;
						if(dp[i+1][j] >= mod) dp[i+1][j] -= mod;
					}
				}
				else{
					if(b[cur]-n-numm-(n-1-cur-j) >= 1){
						dp[i+1][j] += dp[i][j] * (b[cur]-n-numm-(n-1-cur-j)) % mod;
						if(dp[i+1][j] >= mod) dp[i+1][j] -= mod;
					}
					if(a[cur]-one-j >= 1){
						dp[i+1][j+1] += dp[i][j] * (a[cur]-one-j) % mod;
						if(dp[i+1][j+1] >= mod) dp[i+1][j+1] -= mod;
					}
				}
			}
			if(ty == 1) one++;
			else cur--;
		}
		
		assert(one == n && cur == -1);
		if(numm%2 == 0) ans += dp[2*n][numm];
		else ans -= dp[2*n][numm];
	}
	cout << (ans%mod+mod)%mod << endl;
}