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 <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

#define FILL(a, n, x) memset((a), (x), sizeof ((a)[0]) * (n))
#define COPY(a, n, b) memcpy((b), (a), sizeof ((a)[0]) * (n))
#define FILLA(a, x) memset((a), (x), sizeof (a))
#define COPYA(a, b) memcpy((b), (a), sizeof (a))

using namespace std;

typedef long long li;
typedef unsigned long long lu;
const li infl = ~0LLU >> 2;

template <class T>
inline void Min(T &x, T y) {
  if (y < x) x = y;
}
template <class T>
inline void Max(T &x, T y) {
  if (y > x) x = y;
}

// const int mod = 998244353;
int mod;
inline int Add(int x) { return x >= mod ? x - mod : x; }
inline void Add(int &x, int y) { x += y; if (x >= mod) x -= mod; }
inline int Sub(int x) { return x < 0 ? x + mod : x; }
inline void Sub(int &x, int y) { x -= y; if (x < 0) x += mod; }
inline int Mul(int x, int y) { return (int)((li)x * y % mod); }
inline int Mul(int x, int y, int z) { return Mul(x, Mul(y, z)); }
int Pow(int x, int y) {
  int z = 1;
  for (; y; y >>= 1) {
    if (y & 1) z = Mul(z, x);
    x = Mul(x, x);
  }
  return z;
}
int Inv(int x) {
  return Pow(x, mod - 2);
}

// ----------------------------------------

const int maxn = 250;
const double eps = 1e-8;

int n;
int L[maxn * 2], R[maxn * 2];
int ord[maxn * 2];

void GetOrd(void) {
  int i = 0, j = n, k = 0;
  while (i < n && j < 2 * n) {
    if (L[i] > R[j]) {
      ord[k++] = i++;
    } else {
      ord[k++] = j++;
    }
  }
  while (i < n) {
    ord[k++] = i++;
  }
  while (j < 2 * n) {
    ord[k++] = j++;
  }
}

int f[2][maxn + 1][maxn + 1];

int main(void) {
  scanf("%d%d", &n, &mod);
  for (int i = 0; i < 2 * n; ++i) {
    L[i] = i < n ? ceil(sqrt(n * n - i * i) - eps) : 0;
    R[i] = floor(sqrt(4 * n * n - i * i) + eps) + 1;
    Min(R[i], 2 * n);
  }

  GetOrd();

  int cur = 0, nxt = 1;
  FILLA(f[cur], 0);
  for (int k = 0; k <= n; ++k) {
    f[cur][0][k] = 1;
  }

  for (int i = 0; i < 2 * n; ++i) {
    FILLA(f[nxt], 0);
    for (int j = 0; j <= n; ++j) {
      for (int k = 0; k <= n; ++k) {
        int val = f[cur][j][k];
        // if (val) {
        //   fprintf(stderr, "f[%d][%d][%d] = %d\n", i, j, k, val);
        // }
        int selected_large = j;
        int selected_small = i - j;
        int plan_small = 2 * n - k;
        int idx = ord[2 * n - i - 1];
        if (idx < n) {
          Add(f[nxt][j + 1][k],
              Mul(val, max(R[idx] - (plan_small + selected_large), 0)));
          Add(f[nxt][j][k],
              Mul(Sub(-val), max(L[idx] - selected_small, 0)));
        } else {
          Add(f[nxt][j][k],
              Mul(val, max(R[idx] - selected_small, 0)));
        }
      }
    }
    swap(cur, nxt);
  }

  int ans = 0;
  for (int k = 0; k <= n; ++k) {
    Add(ans, f[cur][k][k]);
  }
  printf("%d\n", Sub(ans % mod));
  return 0;
}
