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 FR first
#define SE second

using namespace std;

typedef long long ll;
typedef pair<int,int> pr;

int MOD;

inline void add(int &x,ll y) {
  x=(x+y)%MOD;
}

inline void sub(int &x,ll y) {
  x=(x-y)%MOD;
}

pr num[505];
int f[2][255];

int main() {
  int n;
  scanf("%d%d",&n,&MOD);
  int cnt=0;
  for(int i=0;i<n;i++) {
  	int r1=0;
  	while (r1*r1+i*i<n*n) r1++;
  	int r2=r1;
  	while (r2<2*n-1&&(r2+1)*(r2+1)+i*i<=4*n*n) r2++;
  	num[++cnt]=pr(r1,r2+1);
  }
  for(int i=n;i<2*n;i++) {
  	int r=0;
  	while (r<2*n-1&&(r+1)*(r+1)+i*i<=4*n*n) r++;
  	num[++cnt]=pr(r+1,0);
  }
  sort(num+1,num+cnt+1);
  int ans=0;
  for(int i=0;i<=n;i++) {
  	int cur=0;
  	memset(f[cur],0,sizeof(f[cur]));
  	f[cur][0]=1;
  	int s1=0,s2=0;
  	for(int j=1;j<=cnt;j++) {
  		cur^=1;
  		memset(f[cur],0,sizeof(f[cur]));
  		if (!num[j].SE) {
  			int u=num[j].FR-s2,t=min(i,s1);
  			for(int k=0;k<=t;k++)
  			  if (f[cur^1][k]) add(f[cur][k],(ll)f[cur^1][k]*(u-k));
  			s2++;
		  }
		else {
			int u=num[j].FR-s2,v=num[j].SE-i-n-s1,t=min(i,s1);
			for(int k=0;k<=t;k++)
			  if (f[cur^1][k]) {
			  	add(f[cur][k],(ll)f[cur^1][k]*(v+k));
			  	sub(f[cur][k+1],(ll)f[cur^1][k]*(u-k));
			  }
			s1++;
		}
	  }
	add(ans,f[cur][i]);
  }
  printf("%d\n",(ans+MOD)%MOD);
  return 0;
}