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 <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define sqr(a) ((a) * (a))
using namespace std;
inline char nc() {
    static char buf[100000], *l = buf, *r = buf;
    return l==r&&(r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++;
}
template<class T> void read(T &x) {
    x = 0; int f = 1, ch = nc();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=nc();}
    while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=nc();}
    x *= f;
}
typedef long long ll;
const int maxn = 250 + 5;
int n, m;
int mod;
int f[maxn << 1];
int g[maxn << 1];
int dp[maxn << 1][maxn];
struct data {
    int val;
    int id, type;
    data(int val=0,int id=0,int type=0):val(val), id(id), type(type) {}
    bool operator < (const data &other) const {
        if(val != other.val) return val < other.val;
        return id > other.id;
    }
};
vector<data> A;
inline void update(int &x, int y, int z) {
    if(z < 0) return;
    x = (x + (ll)y * z) % mod;
}
int main() {
    // freopen("F.in", "r", stdin);
    // freopen("F.out", "w", stdout);
    read(n), read(mod);
    for(int i = 0; i < (n << 1); ++i) {
        while(sqr(f[i]) + sqr(i) < sqr(n)) ++f[i];
        while(sqr(g[i]) + sqr(i) <= sqr(n << 1)) ++g[i];
        f[i] = min(f[i], n << 1);
        g[i] = min(g[i], n << 1);
        if(i < n) {
            A.push_back(data(f[i], i, 0));
        }
        else {
            A.push_back(data(g[i], -1, 1));
        }
    }
    sort(A.begin(), A.end());
    int an = 0;
    for(int k = 0, f = 1; k <= n; ++k, f = mod - f) {
        memset(dp, 0, sizeof(dp));
        dp[0][0] = 1;
        int as = 0, bs = 0;
        for(int i = 0; i < (n << 1); ++i) {
            if(A[i].type == 1) {
                for(int j = 0; j <= min(k, as); ++j) {
                    update(dp[i + 1][j], dp[i][j], A[i].val - bs - j);
                }
                ++bs;
            }
            else {
                for(int j = 0; j <= min(k, as); ++j) {
                    update(dp[i + 1][j], dp[i][j], g[A[i].id] - (n + k + as - j));
                    update(dp[i + 1][j + 1], dp[i][j], A[i].val - bs - j);
                }
                ++as;
            }
        }
        an = (an + (ll)f * dp[n << 1][k]) % mod;
    }
    printf("%d\n", an);
    return 0;
}
