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<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int>pii;
ll mod;
ll dp[633][333];
int g1[333], g2[333];
vector<int>d1[333], d2[333];
ll kai[333];
int main()
{
	int num;
	scanf("%d%lld", &num, &mod);
	vector<pii>qs;
	for (int i = 0; i < num; i++)
	{
		int a, b;
		for (int j = 0; j <= num; j++)
		{
			if (i*i + j*j >= num*num)
			{
				a = j;
				break;
			}
		}
		for (int j = num + num - 1; j >= 0; j--)
		{
			if (i*i + j*j <= num*num * 4)
			{
				b = j + 1;
				break;
			}
		}
		qs.push_back(make_pair(a, -(b - num - num + i + 1)));
	}
	for (int i = num; i < num + num; i++)
	{
		for (int j = num + num - 1; j >= 0; j--)
		{
			if (i*i + j*j <= num*num * 4)
			{
				qs.push_back(make_pair(j + 1, 1));
				break;
			}
		}
	}
	sort(qs.begin(), qs.end());
	for (int i = 0; i < qs.size(); i++)qs[i].second = -qs[i].second;
	ll ret = 0;
	//for (int i = 0; i < qs.size(); i++)printf("%d %d\n", qs[i].first, qs[i].second);
	for (int p = 0; p <= num; p++)
	{
		for (int i = 0; i <= num + num; i++)for (int j = 0; j <= num; j++)dp[i][j] = 0;
		dp[0][0] = 1;
		int c1 = 0;
		for (int i = 0; i < qs.size(); i++)
		{
			if (qs[i].second == -1)
			{
				for (int k = 0; k <= min(num, qs[i].first - c1); k++)
				{
					dp[i + 1][k] = dp[i][k] * (qs[i].first - c1 - k) % mod;
				}
				c1++;
			}
			else
			{
				for (int k = 0; k <= min(p, qs[i].first - c1); k++)
				{
					dp[i + 1][k + 1] = (dp[i + 1][k + 1] + mod - dp[i][k] * (qs[i].first - c1 - k) % mod) % mod;
					dp[i + 1][k] = (dp[i + 1][k] + dp[i][k] * max(0, qs[i].second - p + k)) % mod;
				}
			}
			//for (int k = 0; k <= num; k++)printf("%lld ", dp[i + 1][k]); printf("\n");
		}
		ret = (ret + dp[num + num][p]) % mod;
	//	printf("%lld\n", dp[num + num][p]);
	}
	printf("%lld\n", ret);
}