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 <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=250;

int n,mod;

int l[2*MAXN],r[2*MAXN];

pair<int,int> lst[2*MAXN];

int dp[2*MAXN+1][MAXN+1];

void inc(int &a,int b,int c) { a=(a+(ll)b*c)%mod; }
int solve() {
	REP(i,2*n) if(i>=n) l[i]=0; else { l[i]=sqrt(1.0*n*n-i*i); while(l[i]*l[i]<n*n-i*i) ++l[i]; }
	REP(i,2*n) r[i]=min(2*n-1,(int)sqrt(4.0*n*n-i*i));
	//REP(i,2*n) printf("%d: %d..%d\n",i,l[i],r[i]);

	REP(i,2*n) if(i<n) lst[i]=MP(l[i]-1,-i); else lst[i]=MP(r[i],-i);
	sort(lst,lst+2*n);
	REP(i,2*n) lst[i].second=-lst[i].second;
	//printf("lst:"); REP(i,2*n) printf(" (%d,%d)",lst[i].first,lst[i].second); puts("");

	int ret=0;
	REPE(ntot,n) {
		memset(dp,0,sizeof(dp)); dp[0][0]=1%mod;
		int nlft=0,nrgt=0;
		REP(i,2*n) {
			int at=lst[i].second;
			REPE(j,ntot) if(dp[i][j]!=0) {
				if(at>=n) {
					inc(dp[i+1][j],dp[i][j],r[at]+1-(nrgt+j));
				} else {
					inc(dp[i+1][j],dp[i][j],r[at]+1-(n+ntot+nlft-j));
					if(j+1<=ntot) inc(dp[i+1][j+1],dp[i][j],l[at]-(nrgt+j));
				}
			}
			if(at<n) ++nlft; else ++nrgt;
		}
		//printf("%d: %d\n",ntot,dp[2*n][ntot]);
		inc(ret,ntot%2==0?1:mod-1,dp[2*n][ntot]);
	}
	return ret;
}

void run() {
	scanf("%d%d",&n,&mod);
	printf("%d\n",solve());
}

int main() {
	run();
	return 0;
}
