#include using namespace std; using ll=long long; using db=double; const int N=1e6+5; int n,k,f[12*N],ans; inline void solve(){ cin>>n>>k; for(ll i=1;i<=n;i++){ for(ll j=1;j<=n;j++){ f[i*i-j*j+5*N]++; } } for(ll i=1;i<=n;i++){ for(ll j=1;j<=n;j++){ ans+=f[i*i+j*j-k+5*N]; } } cout<>T; while(T--) solve(); }