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 <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int unt;
typedef double db;
typedef pair <int, int> pii;
typedef vector <int> vi;

#define Fi first
#define Se second
#define pb push_back
#define mp make_pair
#define rep(x, a, b) for(int x = (a); x <= (b); ++ x)
#define per(x, a, b) for(int x = (a); x >= (b); -- x)
#define rop(x, a, b) for(int x = (a); x < (b); ++ x)
#define por(x, a, b) for(int x = (a); x > (b); -- x)
#define forE(x, a) for(int x = head[a]; x; x = nxt[x])

#ifdef DEBUG
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define debug(x)
#endif

const db eps = 1e-8;
const int inf = 0x3f3f3f3f;
const int Minf = 0x7f7f7f7f;
const LL INF = 0x3f3f3f3f3f3f3f3fll;
const LL MINF = 0x7f7f7f7f7f7f7f7fll;

const int N = 255;

int a[N], b[N], c[N];
pii p[N << 2]; 
int f[N * 4][N];

int main() {
	int n, mod, ans = 0, tot = 0; scanf("%d%d", &n, &mod);
	rep(i, 0, n - 1) a[i + 1] = ceil(sqrt(n * n - i * i)) - 1;
	rep(i, 0, n - 1) c[i + 1] = floor(sqrt(4 * n * n - i * i));
	rep(i, n, (n << 1) - 1) b[i - n + 1] = floor(sqrt(4 * n * n - i * i));
	rep(i, 0, n - 1) p[++ tot].Fi = min(a[i + 1], (n << 1) - 1), p[tot].Se = 1;
	rep(i, 0, n - 1) p[++ tot].Fi = min(b[i + 1], (n << 1) - 1), p[tot].Se = 2;
	rep(i, 0, n - 1) p[++ tot].Fi = min(c[i + 1], (n << 1) - 1), p[tot].Se = 3;
	sort(p + 1, p + 1 + tot);
	rep(c, 0, n) {
		int nowc = 2 * n + 1;
		int rk = 0;
		memset(f, 0, sizeof f);
		f[0][0] = 1;
		rep(i, 1, n << 1) {
			if(p[i].Se == 2) {
				++ rk;
				rep(j, 0, min(i - 1, c)) {
					int nowrk = j + rk;
					f[i][j] = 1ll * f[i - 1][j] * max((p[i].Fi - nowrk + 2), 0) % mod;
				}
			}
			else {
				rep(j, 0, min(i, c)) {
					int nowrk = j + rk;
					int nowcrk = n + c + nowc - (n << 1) - j;
					if(j >= 0) f[i][j] = 1ll * f[i - 1][j] * max((p[nowc].Fi - nowcrk + 2), 0) % mod;
					if(j > 0) f[i][j] += 1ll * f[i - 1][j - 1] * max((p[i].Fi - nowrk + 2), 0) % mod;
					if(f[i][j] >= mod) f[i][j] -= mod;
				}
				++ nowc;
			}
		}
		ans += (c & 1) ? -f[n << 1][c] : f[n << 1][c];
		if(ans >= mod) ans -= mod;
		if(ans < 0) ans += mod;
	}
	printf("%d\n", ans);
}
