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
/*Lower_Rating*/
/*AGC036 F Square Constraints*/
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;

#define LL long long
#define MAXN 500
#define Pr pair<int,int>
#define X first
#define Y second
#define INF (1LL<<60)
#define mem(x,p) memset(x,p,sizeof(x))

LL read(){
  LL x=0,F=1;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-'0';c=getchar();}
  return x*F;
}
LL MOD;
int add(int x,int y){return (x+y>=MOD)?x+y-MOD:x+y;}
int dec(int x,int y){return (x-y<0)?x-y+MOD:x-y;}
int mul(int x,int y){return 1LL*x*y%MOD;}

int n,tot,ans;
Pr p[MAXN+5];
int dp[MAXN+5][MAXN+5];
int main()
{
    //freopen("square.in","r",stdin);
    //freopen("square.out","w",stdout);
    n=read(),MOD=read();
    for(int i=0,vf=2*n,vg=2*n;i<2*n;i++){
        while(i*i+(vf-1)*(vf-1)>4*n*n&&vf>0)vf--;
        while(i*i+(vg-1)*(vg-1)>=n*n&&vg>0)vg--;
        if(i<n)p[++tot]=Pr(vg,vf);
        else p[++tot]=Pr(vf,0);
    }
    sort(p+1,p+tot+1);
    for(int k=0;k<=n;k++){
        memset(dp,0,sizeof(dp));
        dp[1][0]=1;
        int cntf=0,cntg=0;
        for(int i=1;i<=tot;i++){
            for(int j=0;j<=k;j++)
            if(p[i].Y==0)dp[i+1][j]=add(dp[i+1][j],mul(dp[i][j],(p[i].X-j-cntf)));
            else{
                if(j<k)dp[i+1][j+1]=add(dp[i+1][j+1],mul(dp[i][j],(p[i].X-j-cntf)));
                dp[i+1][j]=add(dp[i+1][j],mul(dp[i][j],(p[i].Y-n-k-(cntg-j))));
            }
            if(p[i].Y==0)cntf++;
            else cntg++;
        }
        if(k%2)ans=dec(ans,dp[tot+1][k]);
        else ans=add(ans,dp[tot+1][k]);
    }
    printf("%d",ans);
}
