/** author: shobonvip created: 2024.10.18 21:21:22 **/ #include using namespace std; //* ATCODER #include using namespace atcoder; typedef modint998244353 mint; //*/ /* BOOST MULTIPRECISION #include using namespace boost::multiprecision; //*/ typedef long long ll; #define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++) #define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--) template bool chmin(T &a, const T &b) { if (a <= b) return false; a = b; return true; } template bool chmax(T &a, const T &b) { if (a >= b) return false; a = b; return true; } template T max(vector &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]); return ret; } template T min(vector &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]); return ret; } template T sum(vector &a){ T ret = 0; for (int i=0; i<(int)a.size(); i++) ret += a[i]; return ret; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int q; cin >> q; const int n = 4001; vector ans(q); vector bucket_1(n+1, vector>(0)); vector bucket_2(n+1, vector>(0)); rep(i,0,q){ int t; cin >> t; int m, k; cin >> m >> k; if (t == 1) { bucket_1[k].push_back(pair(m, i)); } if (t == 2){ bucket_2[m].push_back(pair(k, i)); } } vector dp1(n+1, vector(n+1)); dp1[0][0] = 1; rep(i,1,n+1){ rep(j,0,n+1){ if (j-i >= 0) { dp1[i][j] = dp1[i-1][j] + dp1[i][j-i]; }else{ dp1[i][j] = dp1[i-1][j]; } } } rep(i,1,n+1){ for (auto [mx, ind]: bucket_2[i]) { mint ret = dp1[mx][i]; ans[ind] = ret; } } vector f(n+1); f[0] = 1; rep(i,1,n+1){ rep(j,0,n+1){ if (j-i >= 0) { f[j] += f[j-i]; } } for (auto [mx, ind]: bucket_1[i]) { mint ret = f[mx]; ans[ind] += ret; } } rep(i,0,q){ cout << ans[i].val() << '\n'; } }