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>

#define reg register
#define pr std::pair<int, int>
#define fi first
#define se second
#define FIN(s) freopen(s, "r", stdin)
#define FOUT(s) freopen(s, "w", stdout)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, l, r) for (int i = l; i <= r; ++i)
#define lep(i, l, r) for (int i = l; i < r; ++i)
#define irep(i, r, l) for (int i = r; i >= l; --i)
#define ilep(i, r, l) for (int i = r; i > l; --i)
#define Rep(i, n) rep(i, 1, n)
#define Lep(i, n) lep(i, 1, n)
#define IRep(i, n) irep(i, n, 1)
#define ILep(i, n) ilep(i, n, 1)
typedef long long ll;
typedef long double ld;

namespace modular {
    int MOD;
    inline int add(int x, int y) { return (x += y) >= MOD ? x -= MOD : x; }
    inline void inc(int &x, int y) { (x += y) >= MOD ? x -= MOD : 0; }
    inline int mul(int x, int y) { return 1LL * x * y % MOD; }
    inline int qpow(int x, int y) {
        int ans = 1;
        for (; y; y >>= 1, x = mul(x, x))
            if (y & 1) ans = mul(ans, x);
        return ans;
    }
};  // namespace modular
using namespace modular;

namespace Base {
    template <typename Tp>
    inline Tp input() {
        Tp x = 0, y = 1;
        char c = getchar();
        while ((c < '0' || '9' < c) && c != EOF) {
            if (c == '-') y = -1;
            c = getchar();
        }
        if (c == EOF) return 0;
        while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getchar();
        return x *= y;
    }
    template <typename Tp>
    inline void read(Tp &x) {
        x = input<Tp>();
    }
    template <typename Tp>
    inline void chmax(Tp &x, Tp y) {
        x < y ? x = y : 0;
    }
    template <typename Tp>
    inline void chmin(Tp &x, Tp y) {
        x > y ? x = y : 0;
    }
};  // namespace Base
using namespace Base;
/*----------------------------------------------------------------------------*/

#define MAX_N 507

int N;
int p[MAX_N], f[MAX_N][MAX_N];

struct seg {
    int l, r;
} s[MAX_N];

inline int sqr(int x) { return x * x; }

pr kx, ky;
bool cmp(int x, int y) {
    if (x > N)
        kx.fi = s[x].r, kx.se = 0;
    else
        kx.fi = s[x].l, kx.se = s[x].r;
    if (y > N)
        ky.fi = s[y].r, ky.se = 0;
    else
        ky.fi = s[y].l, ky.se = s[y].r;
    return kx == ky ? x > y : kx < ky;
}

int solve(int k) {
    memset(f, 0, sizeof(f));
    f[0][0] = 1;
    int t = 0;
    Rep(i, N + N) {
        int x = p[i], ed = std::min(i, k);
        rep(j, 0, ed) {
            if (x > N) {
                inc(f[i][j], mul(f[i - 1][j], s[x].r + 1 - (i - 1 - (t - j))));
            } else {
                inc(f[i][j], mul(f[i - 1][j],
                                 s[x].r + 1 - (N * 2 - 1 - (x - 1) + (k - j))));
                if (j > 0)
                    inc(f[i][j], mul(f[i - 1][j - 1],
                                     s[x].l + 1 - (i - 1 - (t - (j - 1)))));
            }
            // if (f[i][j]) printf("%d %d %d\n", i, j, f[i][j]);
        }
        if (x <= N) t++;
    }
    return f[N + N][k];
}

int main() {
    read(N), read(MOD);
    Rep(i, N + N) {
        s[i].l = (i > N ? 0 : (int)sqrt(N * N - sqr(i - 1)));
        s[i].r = (int)sqrt(4 * N * N - sqr(i - 1));
        if (sqr(i - 1) + sqr(s[i].l) < sqr(N)) s[i].l++;
        chmin(s[i].r, N + N - 1);
        if (i <= N) s[i].l = std::max(0, s[i].l - 1);
        p[i] = i;
    }
    std::sort(p + 1, p + N + N + 1, cmp);
    int res = 0;
    rep(k, 0, N) {
        int tmp = solve(k);
        inc(res, (k & 1) ? MOD - tmp : tmp);
    }
    printf("%d\n", res);
    return 0;
}
