#include using namespace std; using ll = long long; const ll mod = 998244353; const int N = 200005; const int INF = 0x3f3f3f3f; ll powmod(ll x, ll y) { ll res = 1; while (y) { if (y & 1) res = res * x % mod; y >>= 1; x = x * x % mod; } return res; } ll pw[N], c[N], c2[N]; ll f[N][15]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int _; cin >> _; vector> qu; int maxn = 0, maxk = 0; for (int i = 0; i < _; i++) { int n, k; cin >> n >> k; maxn = max(maxn, n); maxk = max(maxk, k - 1); qu.push_back({n, k}); } pw[0] = 1; for (int i = 1; i <= maxn; i++) pw[i] = pw[i - 1] * 2 % (mod - 1); for (int i = 2; i <= maxn; i++) { ll e = pw[i - 1] - 2; if (e < 0) e += mod - 1; c[i] = e; } for (int i = 2; i <= maxn; i++) c2[i] = powmod(2, c[i]); if (maxk >= 1) f[1][1] = 1; for (int h = 2; h <= maxn; h++) { for (int k = 0; k <= maxk; k++) { ll s = 0; for (int i = 0; i <= k; i++) { ll A = (i == 0 ? (1ll * c2[h] + f[h - 1][0]) % mod : f[h - 1][i]); ll B = (k - i == 0 ? (1ll * c2[h] + f[h - 1][0]) % mod : f[h - 1][k - i]); s = (s + A * B) % mod; } f[h][k] = s; } } for (auto [n, k] : qu) { if (k - 1 < 0 || k - 1 > maxn) { cout << "0\n"; continue; } if (k >= 2) { cout << f[n][k - 1] << "\n"; } else { ll ans = f[n][0]; if (n >= 2) { ans = (ans + c2[n]) % mod; } else { ans = (ans + 1) % mod; } cout << ans << "\n"; } } return 0; }