#include using namespace std; template struct prefix_binomial_sum { prefix_binomial_sum(int n) : size(n), b(0) {} mint get(int n, int k) { build(); int m = n / b; mint res = table[m][k]; m *= b; while (m < n) { res = 2 * res - binom(m, k); m++; } return res; } private: int size, b; vector fac, finv; vector> table; mint binom(int n, int k) { if (n < k) return mint(); return fac[n] * finv[n - k] * finv[k]; } void build() { if (b > 0) return; b = 450; fac.resize(size + 1); finv.resize(size + 1); table.reserve(size / b); fac[0] = 1; for (int i = 1; i <= size; i++) { fac[i] = i * fac[i - 1]; } finv[size] = fac[size].inv(); for (int i = size; i >= 1; i--) { finv[i - 1] = i * finv[i]; } for (int i = 0; i * b <= size; i++) { vector v(size + 1); v[0] = 1; for (int j = 1; j <= size; j++) { v[j] = v[j - 1] + binom(b * i, j); } table.push_back(v); } } }; #include #include using mint = atcoder::modint998244353; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); prefix_binomial_sum C(200000); int T; cin >> T; while (T--) { int N, M; cin >> N >> M; mint ans = mint(2).pow(N) - 1; ans *= C.get(N - 1, M - 1); cout << ans.val() << '\n'; } }