//
// Created by maze on 2019/09/15.
//

#include <bits/stdc++.h>
using namespace std;

#define INF_LL (int64)1e18
#define INF (int64)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a); i < (b); i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int32_t;
using int64 = int64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

constexpr int64 mod = 998244353;

int64 N, S;

int64 mpow(int64 a, int64 b) {
    if (b == 0) return 1;
    if (b % 2) return a * mpow(a, b-1) % mod;
    int64 ret = mpow(a, b/2);
    return ret*ret%mod;
}

void term_mul(vector<int64>& x, int64 a) { // xの多項式に(x-a)をかける
    REP(i, x.size()-1) {
        x[i] = x[i+1] + x[i] * (mod-a) % mod;
        x[i] %= mod;
//        x[i] = x[i+1] + x[i] * -a;
    }
    x.back() = x.back() * (mod - a) % mod;
//    x.back() = x.back() * -a;
}

vector<int64> term_div(vector<int64> x, int64 a) { // (x-a)で割る
    vector<int64> res(x.size(), 0);
    REP(i, x.size()-1) {
        res[i+1] = x[i];
        x[i+1] += mod-x[i]*(mod-a)%mod;
        x[i+1] %= mod;
    }
    return res;
}

vector<int64> term_sum(const vector<int64>& a, const vector<int64>& b, const int64 co = 1) {
    vector<int64> res(max(a.size(), b.size()), 0);
    REP(i, res.size()) {
        res[i] = a[i] + b[i] * co % mod;
        res[i] %= mod;
//        cout << "(" << a[i] << " " << b[i] << " " << co << " " << res[i] << ") ";
    }
//    cout << endl;
    return res;
}

vector<int64> lagrange(vector<int64>& x, vector<int64>& fx) {
    vector<int64> coeff(N+2, 0);
    vector<int64> all_mul(N+2, 0);
    all_mul.back() = 1;
    REP(i, x.size()) {
        term_mul(all_mul, (mod+x[i])%mod);
    }
    REP(i, x.size()) {
        int64 co = 1;
        REP(j, fx.size()) {
            if (i == j) continue;
            co = co * ((mod+x[i]-x[j])%mod) % mod;
        }
        auto ret = term_div(all_mul, x[i]);

        coeff = term_sum(coeff, term_div(all_mul, x[i]), fx[i]%mod*mpow(co, mod-2)%mod);
    }
    return coeff;
}

int64 apply(const vector<int64>& exp, int64 x) {
    int64 res = 0;
    int64 xx = 1;
    for (int64 i = exp.size()-1; i >= 0; i--) {
        res = (res + xx * exp[i]) % mod;
        xx = xx * x % mod;
    }
    return res;
}

int64 calc(int64 len, int64 val) {
    int64 res = 0;
    if (len <= 4 || len/2 < N) {
        REP(i, len) {
            if (i % 2 == 0)
                res += mpow(val-i-1, N);
            else
                res += mod - mpow(val-i-1, N);
            res %= mod;
        }
    } else {
        int64 idx = (len-1)/2-(1-(len-1)/2%2)+1;
        int64 l = idx-1, r = len-idx;
//        cout << l << " " << idx << " " << r << endl;
        int64 ret = calc(r, 0);
        cout << ret << endl;
        if (N % 2)
            ret += mod - ret;
        else
            ret += ret;
        ret %= mod;
        cout << "idx" << " " << idx << " " << l << " " << r << " " << ret << ": ";
        REP(i, r-l) {
           if (i%2 == 1) {
               ret += (mod - mpow(r-i, N));
           }  else {
               ret += mpow(r-i, N);
           }
           cout << "{" << mpow(r-i, N) << " " << i << "} ";
           ret %= mod;
        }
        cout << ret << endl;

        vector<int64> x(N+1), fx(N+1);
        x[0] = idx++; fx[0] = ret;
        REP(i, N) {
            x[i+1] = idx++;
            ret += mod - mpow(l + i + 1, N);
            ret %= mod;
            if (r % 2 == 0) {
                ret += mpow(mod - r + i , N);
            } else {
                ret += mod - mpow(mod - r + i, N);
            }
            ret %= mod;
            ret = mod - ret;
            fx[i+1] = ret;
        }
        auto exp = lagrange(x, fx);
//        REP(i, x.size()) {
//            cout << "(" << x[i] << " " << fx[i] << ") ";
//        }
//        cout << endl;
//        REP(i, exp.size()) {
//            cout << exp[i] << " ";
//        }
//        cout << endl;
        res = apply(exp, val);
    }
//    cout << len << " " << val << " " << res << endl;
    return res;
}

//int64 calc(int64 len, int64 val) { // (val-1)^N-(val-2)^N+...(len-len)^N
//
//}

int64 calc(int64 S) {
    vector<int64> x(N+1), fx(N+1);
    int64 now = 2-S%2;
    REP(i, N+1) {
        x[i] = now;
        fx[i] = (i > 0 ? fx[i-1] : 0);
        fx[i] += mpow(now, N) - mpow(now-1, N);
        fx[i] = (fx[i] %mod + mod) % mod;
        now += 2;
    }
    auto ret = lagrange(x, fx);
    return apply(ret, S%mod);
}

int main(void) {
    cin >> N >> S;
    int64 res = S*(S+1)%mod;
    res *= mpow(2, mod-2);
    res %= mod;
    res *= mpow(S+1, N-2);
    res %= mod;
    N--;
    res += calc(S);
    res %= mod;
    cout << res << endl;
}


Measured memory_bytes: 3176