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 <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int MAXN=505;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
int mods,n;
PR a[MAXN];
int f[MAXN][MAXN];
int upd(int x,int y) { return x+y>=mods?x+y-mods:x+y; }
int main()
{
	n=read(),mods=read();
	for (int i=0;i<n<<1;i++)
	{
		int y=floor(sqrt(n*n*4-i*i))+1;
		upmin(y,n<<1);
		if (i<n) 
		{
			int x=floor(sqrt(n*n-i*i));
			if (x*x+i*i!=n*n) x++;
			a[i]=MP(x,y);
		}
		else a[i]=MP(y,0);
//		cout<<a[i].fi<<" "<<a[i].se<<endl;
	}
	
	sort(a,a+n*2);
	int ans=0;
	for (int k=0;k<=n;k++)
	{
		memset(f,0,sizeof f); f[0][0]=1;
		int cnt1=0,cnt2=0;
		for (int i=0;i<n<<1;i++)
		{
			for (int j=0;j<=k;j++)
				if (!a[i].se) f[i+1][j]=upd(f[i+1][j],1ll*f[i][j]*(a[i].fi-cnt1-j)%mods);
				else
				{
					if (j<k) f[i+1][j+1]=upd(f[i+1][j+1],1ll*f[i][j]*(a[i].fi-cnt1-j)%mods);
					f[i+1][j]=upd(f[i+1][j],1ll*f[i][j]*(a[i].se-n-k-cnt2+j)%mods);
				}
			if (!a[i].se) cnt1++;
			else cnt2++;
		}
//		cout<<ans<<endl;
		if (k&1) ans=upd(ans,mods-f[n<<1][k]);
		else ans=upd(ans,f[n<<1][k]);
	}
	printf("%d\n",ans);
	return 0;
}