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
// Tenshi ni Fureta yo!

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef unsigned int UI;
typedef pair<int, int> pii;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define MP make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline int chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline int chkmax(T &a, const T &b) { return b > a ? a = b, 1 : 0; }
template<typename T> inline T sqr(const T &val) { return val * val; }

namespace fastIO
{
	const int MAX_BUFFER_SIZE = 1 << 16;

	char buffer[MAX_BUFFER_SIZE], *cur = buffer, *ed = buffer;

	inline char getc() { return *(cur == ed ? ed = buffer + fread(buffer, 1, MAX_BUFFER_SIZE, stdin), cur = buffer : cur)++; }
}
using fastIO::getc;

template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getc());
	for(; !isdigit(ch); ch = getc()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getc()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

// END tpl.

const int MAXN = 500;

int MOD;

int n;

inline void input()
{
	n = read<int>(), MOD = read<int>();
}

inline void solve()
{
	static pii a[MAXN +5];

	for(int i = 0; i < 2 * n; ++i)
		if(i < n)
		{
			for(a[i].fst = 0; a[i].fst < 2 * n && sqr(a[i].fst) + sqr(i) < sqr(n); ++a[i].fst);
			--a[i].fst;
			for(a[i].snd = 0; a[i].snd < 2 * n && sqr(a[i].snd) + sqr(i) <= sqr(2 * n); ++a[i].snd);
			--a[i].snd;
		}
		else
		{
			for(a[i].fst = 0; a[i].fst < 2 * n && sqr(a[i].fst) + sqr(i) <= sqr(2 * n); ++a[i].fst);
			--a[i].fst;
			a[i].snd = 0;
		}

	sort(a, a + 2 * n);

	auto calc = [&] (int k)
	{
		static int f[MAXN + 5][MAXN + 5];
		memset(f, 0, sizeof f);

		f[0][0] = 1;
		for(int cnt1 = 0, cnt2 = 0, i = 0; i < 2 * n; ++i)
			if(a[i].snd == 0)
			{
				for(int j = 0; j <= n; ++j) (f[i + 1][j] += (LL) f[i][j] * (a[i].fst + 1 - cnt1 - j) % MOD) %= MOD;
				++cnt1;
			}
			else
			{
				for(int j = 0; j <= n; ++j)
				{
					(f[i + 1][j + 1] += (LL) f[i][j] * (a[i].fst + 1 - cnt1 - j) % MOD) %= MOD;
					(f[i + 1][j] += (LL) f[i][j] * (a[i].snd + 1 - (n + cnt2 - j + k)) % MOD) %= MOD;
				}
				++cnt2;
			}
		return f[2 * n][k];
	};

	int ans = 0;
	for(int i = 0; i <= n; ++i) (ans += (i & 1 ? -1 : +1) * calc(i)) %= MOD;
	printf("%d\n", (ans + MOD) % MOD);
}

int main()
{
#ifdef K_ON
	freopen("F.in", "r", stdin);
	freopen("F.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}


