#include using namespace std; using ll = long long; using vll = vector; #define sz(x) ((ll)(x).size()) const ll MOD = 1e9+7; template ostream& operator<<(ostream &os, const vector &cont) { for (auto it = cont.begin(); it != cont.end(); ++it) os << (it == cont.begin() ? "" : " ") << *it; return os; } vector>> memo; pair f(ll rad, ll dim) { if (dim == 0) { return {0, 1}; } if (memo[rad][dim].first != -1) { return memo[rad][dim]; } ll r = 0, c = 0; for (ll x = 0; x*x <= rad; ++x) { ll r2, c2; tie(r2, c2) = f(rad - x * x, dim - 1); if (x) c2 *= 2; c = (c + c2) % MOD; r = (r + x * c2 + r2 * (1 + !!x)) % MOD; } // cerr << rad << " " << dim << " " << r << " " << c << endl; return memo[rad][dim] = {r, c}; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll R, D; cin >> D >> R; memo.resize(R*R+10, vector>(D + 1, make_pair(-1ll, -1ll))); cout << f(R*R, D).first << endl; }