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 <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (register ll i = (a); i <= (b); ++i)
#define per(i, a, b) for (register ll i = (a); i >= (b); --i)
#define loop(it, v) for (auto it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (register int i = head[x]; i; i = edge[i].nex)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, cnt) memset(a, cnt, sizeof(a))
#define cop(a, b) memcpy(a, b, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define SC(t, x) static_cast <t> (x)
#define ub upper_bound
#define lb lower_bound
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fi first
#define se second
#define y1 y1_
#define Pi acos(-1.0)
#define iv inline void
#define enter putchar('\n')
#define siz(x) ((int)x.size())
#define file(x) freopen(x".in", "r", stdin),freopen(x".out", "w", stdout)
typedef double db ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <int, int> pii ;
typedef vector <int> vi ;
typedef vector <pii> vii ;
typedef queue <int> qi ;
typedef queue <pii> qii ;
typedef set <int> si ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int maxn = 5e2 + 5 ;
const int inf = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const ll mod = 20000116 ;
const double eps = 1e-7 ;
template <class T = int> T read()
{
	T f = 1, a = 0;
	char ch = getchar() ;
	while (!isdigit(ch)) { if (ch == '-') f = -1 ; ch = getchar() ; }
	while (isdigit(ch)) { a =  (a << 3) + (a << 1) + ch - '0' ; ch = getchar() ; }
	return a * f ;
}

ll n, m, ans, tot;

ll f[maxn], g[maxn], sumc[maxn], h[maxn][maxn], pos[maxn], cnt, rnk[maxn], idx[maxn];

pair <ll, ll> c[maxn << 1];

signed main()
{
	scanf("%lld %lld", &n, &m);
	rep(i, 0, n + n - 1)
	{
		if(i < n) f[i] = ll(floor(sqrt(n * n - i * i - 1))) + 1;
		g[i] = min(ll(floor(sqrt(4 * n * n - i * i)) + 1), n + n);
	}
	rep(i, 0, n - 1) c[++ tot] = mp(f[i], 1 + (i << 2));
	rep(i, 0, n - 1) c[++ tot] = mp(g[i], 2 + (100000 << 2));
	rep(i, n, n + n - 1) c[++ tot] = mp(g[i], 3 + (10000 << 2));
	sort(c + 1, c + tot + 1);
	rep(i, 1, tot)
	{
		if((c[i].se & 3) == 1) pos[++ cnt] = i, rnk[i] = cnt, idx[i] = n + n + cnt;
		sumc[i] = sumc[i - 1] + ((c[i].se & 3) == 3);
	}
	rep(k, 0, n)
	{
		clr(h);
		h[0][0] = 1;
		rep(i, 1, n + n) rep(j, 0, k)
		{
			if((c[i].se & 3) == 3) (h[i][j] += h[i - 1][j] * (c[i].fi - (j + sumc[i] - 1)) % m) %= m;
			else
			{
				(h[i][j] += h[i - 1][j] * (c[idx[i]].fi - (n + k + (i - 1 - sumc[i] - j))) % m) %= m;
				if(j) (h[i][j] += h[i - 1][j - 1] * (c[i].fi - (j + sumc[i] - 1)) % m) %= m;
			}
		}
		// printf("sum : %lld\n", h[n + n][k]);
		(ans += (k & 1 ? m - 1 : 1) * h[n + n][k] % m) %= m;
	}
	printf("%lld\n", ans);
	return 0;
}