#include using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; #include using mint = atcoder::modint998244353; int main() { cin.tie(nullptr)->sync_with_stdio(false); int t; cin >> t; while (t--) { int n, k; cin >> n >> k; mint ans = 0; for (int i = 1; i <= k; ++i) ans += mint(i + 1).pow(n); cout << ans.val() << '\n'; } return 0; }