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>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N = 555;
typedef pair<int , int> pii;
#define mp make_pair
#define fi first
#define se second

int n , mod;
int cnt[N] , dp[2][N];
pii a[N];

template <typename T> inline void chkmin(T &x , T y) { x = min(x , y); }
template <typename T> inline void chkmax(T &x , T y) { x = max(x , y); }
template <typename T> inline void read(T &x)
{
   T f = 1; x = 0;
   char c = getchar();
   for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
   for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + c - '0';
   x *= f;
}
inline void add(int &x , int y) {
	x += y;
	while (x >= mod) x -= mod;
}
inline int solve(int k) {
	memset(dp , 0 , sizeof(dp));
	dp[0][0] = 1;
	for (int i = 0; i < 2 * n; ++i) {
		int now = i & 1 , nxt = now ^ 1;
		memset(dp[nxt] , 0 , sizeof(dp[nxt]));
		for (int j = 0; j <= k; ++j) {
			if (a[i].se == -1) {
				int b = a[i].fi - cnt[i] - j;
				if (b > 0) dp[nxt][j] = (dp[nxt][j] + 1ll * dp[now][j] * b % mod) % mod;
			}  else {
				int b = a[i].se - (i + (k - j) + cnt[2 * n] - cnt[i]);
				if (b > 0) dp[nxt][j] = (dp[nxt][j] + 1ll * dp[now][j] * b % mod) % mod;
				b = a[i].fi - cnt[i] - j;
				if (b > 0 && j < k) dp[nxt][j + 1] = (dp[nxt][j + 1] + 1ll * dp[now][j] * b % mod) % mod;
			}
		} 
	}
	return dp[0][k];
}

int main()	{
	
	read(n); read(mod);
	for (int i = 0; i < 2 * n; ++i) {
		int x = 0;
		while (i * i + x * x < n * n) ++x;
		int y = x;
		while (y < 2 * n && i * i + y * y <= 4 * n * n) ++y;
		if (x == 0) a[i] = mp(y , -1);
		else a[i] = mp(x , y);
	}
	sort(a , a + 2 * n);
	for (int i = 0; i < 2 * n; ++i) {
		cnt[i + 1] = cnt[i];
		if (a[i].se == -1) ++cnt[i + 1];
	}
	int ans = 0;
	for (int k = 0; k <= n; ++k) {
		int val = solve(k);
		if (k & 1) ans = (ans - val + mod) % mod;
		else ans = (ans + val) % mod;
	}	
	printf("%lld\n" , ans);
	
    return 0;
}
