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>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define fi first
#define se second
using namespace std;
typedef long long LL;
const int N = 255;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

namespace ModCalculator {

int MOD;

inline void Inc(int &x, int y) {
	x += y; if (x >= MOD) x -= MOD;
}
inline void Dec(int &x, int y) {
	x -= y; if (x < 0) x += MOD;
}
inline int Add(int x, int y) {
	Inc(x, y); return x;
}
inline int Sub(int x, int y) {
	Dec(x, y); return x;
}
inline int Mul(int x, int y) {
	return 1LL * x * y % MOD;
}

}
using namespace ModCalculator;

int n, nn;
pair<int, int> p[N << 1];
int dp[N << 1][N];

inline int lim(int i, int up) {
	int ret = nn - 1;
	while (i * i + ret * ret > up) --ret;
	return ret + 1;
}

void init() {
	read(n); read(MOD);
	nn = n + n;
	for (int i = 0; i < nn; ++i) {
		if (i < n) {
			p[i] = make_pair(lim(i, n * n - 1), lim(i, 4 * n * n));
		} else {
			p[i] = make_pair(lim(i, 4 * n * n), 0);
		}
	}
	sort(p, p + nn);
}

void solve() {
	int ans = 0;
	for (int k = 0; k <= n; ++k) {
		mset(dp, 0);
		dp[0][0] = 1;
		int c1 = 0, c2 = 0;
		for (int i = 0; i < nn; ++i) {
			if (p[i].se == 0) {
				for (int j = 0; j <= k; ++j) {
					Inc(dp[i + 1][j], Mul(dp[i][j], p[i].fi - c1 - j));
				}
				++c1;
			} else {
				for (int j = 0; j <= k; ++j) {
					if (j < k) Inc(dp[i + 1][j + 1], Mul(dp[i][j], p[i].fi - c1 - j));
					Inc(dp[i + 1][j], Mul(dp[i][j], p[i].se - n - k - c2 + j));
				}
				++c2;
			}
		}
		(k & 1)? Dec(ans, dp[nn][k]) : Inc(ans, dp[nn][k]);
	}
	printf("%d\n", ans);
}

int main() {
	init();
	solve();
	return 0;
}
