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
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int MAX = 501;
int n,m;
void add(int &a,int b){
  a += b;
  if(a > m)
    a -= m;
}
void sub(int &a,int b){
  a -= b;
  if(a < 0)
    a += m;
}
int mul(int a,int b){
  return a * b % m;
}
int kw(int x){
  return x * x;
}
int mi[MAX],ma[MAX];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n >> m;
  R(i,n*2){
    while(kw(mi[i]) + kw(i) < kw(n))mi[i]++;
    while(kw(ma[i]) + kw(i) <= kw(2 * n))ma[i]++;
    mini(ma[i],n*2);
    debug(mi[i],ma[i]);
  }
  int res = 0;
  R(zle,n + 1){
    debug(zle);
    vector<int> dp(zle + 1);
    dp[0] = 1;
    int i = 0, j = n;
    while(i < n || j < 2 * n){
      vector<int> ak(zle+1);
      if(i != n && (j == 2 * n || mi[i] > ma[j])){
        R(k, zle + 1){
          add(ak[k], mul(dp[k], ma[i] - n - (n - i - 1 + k)));
          if(k != zle)
            add(ak[k+1], mul(dp[k], mi[i] - (2 * n - j) - (zle - k - 1)));
        }
        i++;
      }else{
        R(k, zle + 1)
          ak[k] = mul(dp[k], ma[j] - (2 * n - j - 1) - (zle - k));
        j++;
      }
      swap(ak,dp);
     // debug(i,j,dp);
    }
    if(zle & 1){
      sub(res, dp[zle]);
    }else{
      add(res, dp[zle]);
    }
  }
  cout << res << "\n";
}
