Problem:
Score : 900 points

Problem Statement

We have a sequence of N integers: x=(x_0,x_1,\cdots,x_{N-1}).
Initially, x_i=0 for each i (0 \leq i \leq N-1).

Snuke will perform the following operation exactly M times:

Choose two distinct indices i, j (0 \leq i,j \leq N-1,\ i \neq j).
Then, replace x_i with x_i+2 and x_j with x_j+1.

Find the number of different sequences that can result after M operations.
Since it can be enormous, compute the count modulo 998244353.

Constraints

2 \leq N \leq 10^6

1 \leq M \leq 5 \times 10^5

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M

Output

Print the number of different sequences that can result after M operations, modulo 998244353.

Sample Input 1

2 2

Sample Output 1

3

After two operations, there are three possible outcomes:

x=(2,4)

x=(3,3)

x=(4,2)

For example, x=(3,3) can result after the following sequence of operations:

First, choose i=0,j=1, changing x from (0,0) to (2,1).

Second, choose i=1,j=0, changing x from (2,1) to (3,3).

Sample Input 2

3 2

Sample Output 2

19

Sample Input 3

10 10

Sample Output 3

211428932

Sample Input 4

100000 50000

Sample Output 4

3463133

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 998244353;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; assert(scanf("%lld", &x) == 1); return x;}
ld fin(){double x; assert(scanf("%lf", &x) == 1); return x;}
char yuyushiki[1000010]; string stin(){assert(scanf("%s", yuyushiki) == 1); return yuyushiki;}

// head

struct Mod{
  unsigned n;
  Mod() : n(0){}
  Mod( ll x ){
    if( x < 0 ) n = x%MOD+MOD;
    else n = x%MOD;
  }
};
Mod operator + ( Mod a  , Mod b ){ return Mod( a.n + b.n ); }
Mod operator +=( Mod &a , Mod b ){ return a = a + b; }
Mod operator - ( Mod a ){ return Mod( MOD - a.n ); }
Mod operator - ( Mod a  , Mod b ){ return Mod( a.n + MOD - b.n ); }
Mod operator -=( Mod &a , Mod b ){ return a = a - b; }
Mod operator * ( Mod a  , Mod b ){ return Mod( (ll)a.n * b.n ); }
Mod operator *=( Mod &a , Mod b ){ return a = a * b; }
Mod modpow( Mod x , ll k ){
  Mod res = 1;
  while( k ){
    if( k & 1 ) res *= x;
    k /= 2;
    x *= x;
  }
  return res;
}
ll extgcd( ll a , ll b , ll &x , ll &y ){
  ll d = a;
  if( b != 0 ){
    d = extgcd( b , a % b , y , x );
    y -= a / b * x;
  } else {
    x = 1, y = 0;
  }
  return d;
}
Mod inv( Mod a ){ ll x, y; assert( extgcd( a.n , MOD , x , y ) == 1 ); return Mod( x ); }
Mod operator / ( Mod a  , Mod b ){ return Mod( (ll)a.n * inv(b).n ); }
Mod operator /=( Mod &a , Mod b ){ return a = a / b; }

struct Factorial{
  vector<Mod> v;
  Factorial( int max_n ){
    v = vector<Mod>( max_n , 1 );
    FOR( i , 1 , max_n ) v[i] = v[i-1] * i;
  }
  int size(){
    return v.size();
  }
  Mod operator [] ( int id ){
    return v.at(id);
  }
};

struct Factorial_inv{
  vector<Mod> v;
  Factorial_inv( Factorial &f ){
    v = vector<Mod>( f.size() );
    REP( i , f.size() ) v[i] = inv( f[i] );
  }
  Mod operator [] ( int id ){
    return v.at(id);
  }
};

struct Combination{
  Factorial *f;
  Factorial_inv *finv;
  Combination( Factorial &arg_f , Factorial_inv &arg_finv ){
    f = &arg_f;
    finv = &arg_finv;
  }
  Mod operator () ( int a , int b ){
    return (*f)[a] * (*finv)[b] * (*finv)[a-b];
  }
};

Factorial fact( 3000010 );
// Factorial fact( 1000010 );
Factorial_inv finv( fact );
Combination comb( fact , finv );

Mod dp[100][100][100];
void naive(){
  ll n = in();
  ll m = in();
  dp[0][0][0] = 1;
  REP(i, n){
    REP(j, 3 * m + 1){
      REP(k, m + 1){
        REP(l, 2 * m + 1){
          ll nj = j + l;
          ll nk = k;
          if(l % 2 == 1){
            nk += 1;
          }
          dp[i+1][nj][nk] += dp[i][j][k];
        }
      }
    }
  }
  Mod ans = 0;
  REP(k, m + 1){
    cout << dp[n][3 * m][k].n << endl;
    ans += dp[n][3 * m][k];
  }
  cout << ans.n << endl;
}


Mod sum[1000010];

int main(){
  
  ll n = in();
  ll m = in();

  /*
  int a = 0;
  int b = 0;
  REP(i, 10){
    REP(j, 10){
      REP(k, 10){
        if((i + j + k) == 3 * m && max({i, j, k}) <= 2 * m && (i % 2 + j % 2 + k % 2 <= m)){
          cout << i << " " << j << " " << k << endl;
          if(i % 2 + j % 2 + k % 2 == 0){
            a++;
          } else {
            b++;
          }
        }
      }
    }
  }

  cout << a << " " << b << endl;
  */
  
  sum[0] = 1;
  REP(i, m + 1){
    sum[i+1] = sum[i] + comb(n-2+i+1, i+1);
  }

  Mod ans = 0;
  REP(k, m + 1){
    // cout << k << endl;
    if(k > n){
      break;
    }
    ll res = 3 * m - k;    
    if(res % 2 == 1){
      continue;
    }
    Mod cur = 0;
    ans += comb(n, k) * comb(res / 2 + n - 1, n - 1); // ignore max constraint
    // cout << "# " << (comb(n, k) * comb(res / 2 + n - 1, n - 1)).n << endl;
    cur += comb(n, k) * comb(res / 2 + n - 1, n - 1); // ignore max constraint
    // cout << cur.n << endl;
    if(res >= 2 * m){
      ans -= comb(n, k) * k * sum[(res - 2 * m) / 2]; // violate odd
      cur -= comb(n, k) * k * sum[(res - 2 * m) / 2]; // violate odd
      // cout << "% " << (comb(n, k) * k * sum[(res - 2 * m) / 2]).n << endl;
    }
    if(res >= 2 * m + 2){ 
      ans -= comb(n, k) * (n - k) * sum[(res - 2 * m - 2) / 2]; // violate even
      cur -= comb(n, k) * (n - k) * sum[(res - 2 * m - 2) / 2]; // violate even
      // cout << "! " << (comb(n, k) * (n - k) * sum[(res - 2 * m - 2) / 2]).n << endl;
    }
    // cout << cur.n << endl;
  }

  cout << ans.n << endl;
  
  return 0;
}