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
//#define DEBUG
//#define USEPB_DS
#define USETR1
#define CPPELEVEN
#define GPP

/*
 * temp.cpp
 *
 *  Created on: 2012-7-18
 *      Author: BSBandme
 */
//#pragma comment(linker, "/STACK:1024000000,1024000000")

#include <bits/stdc++.h>

using namespace std;

#define mpr make_pair
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long long ll;
typedef pair <int, int> pii;



const int maxn = 255;
pii range[maxn * 2];
ll dp[maxn][maxn];
int to[maxn];
int n, mod;

int main() {
  //....................................................................
  ios_base::sync_with_stdio(0);
  #ifdef DEBUG //......................................................................................................
  freopen("input.txt", "r", stdin);
  #endif //...........................................................................................................

  cin >> n >> mod;
  for (int i = 0; i < 2 * n; i++) {
    for (int j = 0; j < 2 * n; j++) {
      if (j * j + i * i < n * n) range[i].first = j + 1;
      if (j * j + i * i <= 4 * n * n) range[i].second = j + 1;
    }
  }

  ll ans = 0;
  for (int cnt = 0; cnt <= n; cnt++) {
	  memset(dp, 0, sizeof(dp));
	  dp[n][0] = 1;
	  int l = 2 * n - 1;
	  for (int i = n - 1; i >= 0; i--) {
		  int rl = l;
		  for (int j = 0; j < min(n - i, cnt + 1); j++) {
			  ll rans = dp[i + 1][j];
			  if (!rans) continue;
			  l = rl;
			  while (l >= n && range[l].second <= range[i].first) {
				  rans = rans * (range[l].second - j - 2 * n + 1 + l) % mod;
				  l--;
			  }
			  dp[i][j + 1] += rans * max(0, (range[i].first - (j + 2 * n - 1 - l))) % mod;
			  if (dp[i][j + 1] >= mod) dp[i][j + 1] -= mod;
			  dp[i][j] += rans * max(0, range[i].second - (2 * n - 1 - i + cnt - j)) % mod;
			  if (dp[i][j] >= mod) dp[i][j] -= mod;
		  }
	  }
	  while (l >= n) {
		  dp[0][cnt] *= range[l].second - cnt - 2 * n + 1 + l;
		  dp[0][cnt] %= mod;
		  l--;
	  }
	  ans += dp[0][cnt] * ((1 - cnt % 2) * 2 - 1);
  }
  cout << (ans % mod + mod) % mod << endl;

  return 0;
}
