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<cctype>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<vector>
using namespace std;
typedef long long lld;
typedef long double lf;
typedef unsigned long long uld;
typedef pair<int,int> pii;
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
namespace RA{
    int r(int p){return 1ll*rand()*rand()%p;}
    int r(int L,int R){return r(R-L+1)+L;}
}/*}}}*/
/******************heading******************/
const int N=1000;

int n,P;
int F[N][N];

int f(int i){
    return sqrt(n*n-i*i-1)+1;
}
int g(int i){
    return min(n*2,(int)sqrt(4*n*n-i*i)+1);
}
int sig(int x){
    return 1-2*(x&1);
}
pair<int,int> A[N*3];
int lh;
int b[N];

signed main(){
    scanf("%d%d",&n,&P);
    FOR(i,0,n-1)A[++lh]={f(i),1};//a
    FOR(i,0,n-1)A[++lh]={g(i),3};//b
    //FOR(i,0,n-1)printf("f(%d)=%d <= P_%d < g(%d)=%d\n",i,f(i),i,i,g(i));
    FOR(i,n,n*2-1)A[++lh]={g(i),2};//c
    //FOR(i,n,n*2-1)printf("0 <= P_%d < g(%d)=%d\n",i,i,g(i));
    sort(A+1,A+lh+1);
    int pos=n*2;
    FOR(i,1,n*2){
        assert(A[i].se!=3);
        if(A[i].se==1){
            b[i]=++pos;
            //printf("b[%d]=%d\n",i,b[i]);
        }
    }
    //FOR(i,1,lh)printf("(%d,%c)%c",A[i].fi,"acb"[A[i].se-1]," \n"[i==lh]);
    assert(pos==n*3);
    int ans=0;
    FOR(k,0,n){
        //printf("\033[33mk=%d\033[0m\n",k);
        int C=0;//统计之前出现过多少个c
        //memset(F,0,sizeof(F));
        F[0][0]=1;
        //printf("F[%d,%d]=%d\n",0,0,F[0][0]);
        FOR(i,1,n*2){
            FOR(j,0,k){
                F[i][j]=0;
            }
            //printf("C=%d\n",C);
            if(A[i].se==1){//a
                FOR(j,0,k) {
                    F[i][j]=(1ll*F[i-1][j]*(A[b[i]].fi-((i-1-C-j)+n+k))%P+(j==0?0ll:1ll*F[i-1][j-1]*(A[i].fi-(j-1+C))))%P;
                    //printf("F(%d,%d) = F(%d,%d) * %d + F(%d,%d) * %d\n",i,j,i-1,j, (A[b[i]].fi-((i-1-C-j)+n+k)), i-1,j-1,(A[i].fi-(j-1)));
                }
            }else {//c
                //printf("C=%d\n",C);
                FOR(j,0,k) F[i][j]=F[i-1][j]*1ll*(A[i].fi-(j+C))%P;
                ++C;
            }
            //FOR(j,0,k){ if(F[i][j])printf("F[%d,%d]=%d\n",i,j,F[i][j]); }
        }
        ans=(ans+F[n*2][k]*sig(k))%P;
    }
    ans=(ans+P)%P;
    printf("%d\n",ans);
    return 0;
}
