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;
#define rep(i,a,b) for (int i = (a); i <= (b); ++ i)
#define rrp(i,a,b) for (int i = (a); i >= (b); -- i)
#define gc() getchar()
#define fir first
#define sec second
typedef pair<int,int> pii;
typedef long double db;
typedef long long ll;
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc(); !isdigit(tmp); tmp = gc())
    key = (tmp == '-');
  for (; isdigit(tmp); tmp = gc()) 
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}
template <typename tp>
inline void ckmn(tp& x,tp y) {
  x = x < y ? x : y;
}
template <typename tp>
inline void ckmx(tp& x,tp y) {
  x = x < y ? y : x;
}

int MOD;
inline void Add(int& x,int y) {
  x = x + y >= MOD ? x + y - MOD : x + y;
}
inline void Sub(int& x,int y) {
  x = x - y < 0 ? x - y + MOD : x - y;
}
int power(int a,int b) {
  int ret = 1;
  while (b) {
    if (b&1) ret = 1ll * ret * a % MOD;
    a = 1ll * a * a % MOD;
    b >>= 1;
  }
  return ret;
}

const int N = 260;
int dp[N * 2][N], n, ans;
pii arr[N << 1];
int calc(int lim) {
  int ret = 0;
  while ((ret + 1) * (ret + 1) <= lim)
    ++ ret;
  return ret;
}
void doit(int num) {
  // j * j <= n * n - i * i - 1
  rep (i, 0, n-1)
    arr[i+1] = pii(calc(n*n - i*i - 1), i);
  rep (i, n, 2 * n - 1)
    arr[i+1] = pii(min(calc(4 * n * n - i * i), 2 * n - 1), i);
  sort(arr + 1, arr + 2 * n + 1, [=](pii a,pii b) -> bool {
      if (a.fir != b.fir) return a.fir < b.fir;
      return a.sec > b.sec;
    });
  memset(dp, 0, sizeof dp);
  dp[0][0] = 1;
  int cur = 0;
  rep (i, 1, 2 * n) {
    if (arr[i].sec >= n) {
      rep (j, 0, n)
	Add(dp[i][j], 1ll * dp[i-1][j] * max(0, (arr[i].fir + 1 - cur - j)) % MOD);
      ++ cur;
    } else {
      int tmp = calc(4 * n * n - arr[i].sec * arr[i].sec); tmp = min(tmp, 2 * n - 1);
      rep (j, 0, n) {
	Add(dp[i][j], 1ll * dp[i-1][j] * max(0, (tmp+1 - n - num - (i-1-cur-j))) % MOD);
	Add(dp[i][j+1], 1ll * dp[i-1][j] * max(0, arr[i].fir+1 - cur - j) % MOD);
      }
    }
  }
  if (num&1) Sub(ans, dp[2*n][num]);
  else Add(ans, dp[2*n][num]);
}
int main() {
  read(n), read(MOD);
  rep (i, 0, n) doit(i);
  cout << ans << endl;
  return 0;
}
