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 <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#include <assert.h>
#define Endl endl
#define mp make_pair
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define srand() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l,r) uniform_int_distribution<int>(l,r)(rng)
typedef unsigned long long ull;
const int inf=1039074182;
using namespace std;
int n,mod;
int dp[505][255];
pair<int,int> a[505];

int mul(int a,int b)
{
	return (1LL*a*b)%mod;
}

int add(int a,int b)
{
	int t=a+b;
	if(t>=mod) t-=mod;
	return t;
}

int sub(int a,int b)
{
	int t=a-b;
	if(t<0) t+=mod;
	return t;
}

int main()
{
//	freopen("input.txt","r",stdin);
	cin>>n>>mod;
	for(int i=0;i<n;i++)
	{
		for(int x=0;x<2*n;x++)
		{
			if(x*x+i*i>=n*n) break;
			a[i].first=x;
		}
		for(int x=0;x<2*n;x++)
		{
			if(x*x+i*i>4*n*n) break;
			a[i].second=x;
		}
	}
	for(int i=n;i<2*n;i++)
	{
		for(int x=0;x<2*n;x++)
		{
			if(x*x+i*i>4*n*n) break;
			a[i].first=x;
		}
		a[i].second=-1;
	}
	sort(a,a+2*n);
//	for(int i=0;i<2*n;i++)
//	{
//		cout<<a[i].first<<' '<<a[i].second<<endl;
//	}
	int res=0;
	for(int k=0;k<=n;k++)
	{
		memset(dp,0,sizeof(dp));
		dp[0][0]=1;
		for(int i=0;i<2*n;i++)
		{
			for(int j=0;j<=n;j++)
			{
				if(a[i].second==-1)
				{
					dp[i+1][j]=add(dp[i+1][j],mul(dp[i][j],max(0,a[i].first+1-(i-j))));
				}
				else
				{
					dp[i+1][j+1]=add(dp[i+1][j+1],mul(dp[i][j],max(0,a[i].second+1-(2*n-k+j))));
					dp[i+1][j]=add(dp[i+1][j],mul(dp[i][j],max(0,a[i].first+1-(i-j))));
				}
			}
		}
		if((n-k)&1) res=sub(res,dp[2*n][k]);
		else res=add(res,dp[2*n][k]);
//		cout<<dp[2*n][k]<<endl;
	}
	cout<<res<<endl;
//	if(!(n&1)) cout<<res<<endl;else cout<<sub(0,res)<<endl;
	return 0;
}