#include<bits/stdc++.h>
using namespace std;
const int N = 251;
#define fr(i,a,b) for(int i = a;i <= b; ++i)
#define nfr(i,a,b) for(int i = a;i >= b; --i)

int n,m;

inline int up(int x){
   return min((int)sqrt(4*n*n-x*x),2*n-1);
}

inline int down(int x){
   if(x >= n)return 0;
   return ceil(sqrt(n*n-x*x))-1;
}

int a[N],f[N][N];

inline void add(int &x,int y){
   x += y; if(x >= m)x -= m;
}

int main(){
   scanf("%d%d",&n,&m);
   
   int ans = 0;
   fr(i,0,n){
      int j = 2*n-1;
      memset(f,0,sizeof f);
      f[n][0] = 1;
      int cnt = 0;
      nfr(k,n-1,0){
         while(j >= n && up(j) <= down(k)){
            fr(l,0,i)f[k+1][l] = 1LL*f[k+1][l]*(1+up(j)-l-(2*n-1-j))%m;
            --j;
         }
         fr(l,0,i)add(f[k][l],1LL*f[k+1][l]*(1+up(k)-(2*n-1-(k-(i-l))))%m);
         fr(l,0,i-1)add(f[k][l+1],1LL*f[k+1][l]*(1+down(k)-l-(2*n-1-j))%m);
      }
      while(j >= n){
         f[0][i] = 1LL*f[0][i]*(1+up(j)-i-(2*n-1-j))%m;
         --j;
      }
      add(ans,(int)pow(-1,i)*f[0][i]);
      if(ans < 0)ans += m;
   }
   printf("%d\n",ans);
   return 0;
}
