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 <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
const int Max_N(255);

int N, MOD, L[Max_N << 1], R[Max_N << 1], F[2][Max_N];

inline int Add(int a, int b)
{
	return a + b >= MOD ? a + b - MOD : a + b;
}

inline int Sub(int a, int b)
{
	return a - b < 0 ? a - b + MOD : a - b;
}

inline int Mult(int a, int b)
{
	return a * 1LL * b % MOD;
}

inline void upd(int &a, int b)
{
	a = Add(a, b);
}

inline void inc(int &a, int b)
{
	a = Sub(a, b);
}

int main()
{
	scanf("%d%d", &N, &MOD);
	if (MOD == 1)
	{
		printf("0");
		return 0;
	}
	for (int i = 0;i < 2 * N;++i)
	{
		L[i] = 0;
		while (i * i + L[i] * L[i] < N * N)
			++L[i];
		R[i] = 2 * N - 1;
		while (i * i + R[i] * R[i] > (2 * N) * (2 * N))
			--R[i];
	}
	int Ans = 0;
	for (int x = 0, now, lst;x <= N;++x)
	{
		now = 0, lst = 1, memset(F[now], 0, sizeof(F[now])), F[now][0] = 1;
		for (int i = N - 1, j = 2 * N - 1, cnt = 0;i >= 0;--i)
		{
			while (j >= N && R[j] <= L[i] - 1)
			{
				for (int k = 0;k <= x;++k)
					if (R[j] + 1 > cnt + k)
						F[now][k] = Mult(F[now][k], (R[j] + 1) - (cnt + k));
					else
						F[now][k] = 0;
				++cnt, --j;
			}
			now ^= 1, lst ^= 1, memset(F[now], 0, sizeof(F[now]));
			for (int k = 0;k <= x;++k)
			{
				if (R[i] + 1 > (2 * N - 1 - i) + (x - k))
					upd(F[now][k], Mult(F[lst][k], (R[i] + 1) - (2 * N - 1 - i) - (x - k)));
				if (k + 1 <= x && L[i] > cnt + k)
					inc(F[now][k + 1], Mult(F[lst][k], L[i] - (cnt + k)));
			}
			if (i == 0)
				while (j >= N)
				{
					for (int k = 0;k <= x;++k)
						if (R[j] + 1 > cnt + k)
							F[now][k] = Mult(F[now][k], (R[j] + 1) - (cnt + k));
						else
							F[now][k] = 0;
					++cnt, --j;
				}
		}
		upd(Ans, F[now][x]);
	}
	printf("%d", Ans);
	return 0;
}