//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

/*
#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
*/
 
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"  //インタラクティブで消す！！！！！！！！！！！！！！！！！！！！！
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=50000;
    rep(y,1,P){
        ll x=mod(y*k);
        
        if(abs(x)<=P||x+P>=i_7){
            if(x+P>=i_7){
                x-=i_7;
            }
            cout<<x<<"/"<<y<<endl;
            //cout<<setprecision(5)<<(dd)x/(dd)y;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
//////////////////////////


//from chocorusk https://yukicoder.me/submissions/488554

const ll MOD=998244353;
template< ll mod >
struct NumberTheoreticTransform {

  vector< ll > rev, rts;
  ll base, max_base, root;

  NumberTheoreticTransform() : base(1), rev{0, 1}, rts{0, 1} {
    assert(mod >= 3 && mod % 2 == 1);
    auto tmp = mod - 1;
    max_base = 0;
    while(tmp % 2 == 0) tmp >>= 1, max_base++;
    root = 2;
    while(mod_pow(root, (mod - 1) >> 1) == 1) ++root;
    assert(mod_pow(root, mod - 1) == 1);
    root = mod_pow(root, (mod - 1) >> max_base);
  }

  inline ll mod_pow(ll x, ll n) {
    ll ret = 1;
    while(n > 0) {
      if(n & 1) ret = mul(ret, x);
      x = mul(x, x);
      n >>= 1;
    }
    return ret;
  }

  inline ll inverse(ll x) {
    return mod_pow(x, mod - 2);
  }

  inline ll add(ll x, ll y) {
    x += y;
    if(x >= mod) x -= mod;
    return x;
  }

  inline ll mul(ll a, ll b) {
    return 1ull * a * b % mod;
  }

  void ensure_base(ll nbase) {
    if(nbase <= base) return;
    rev.resize(1 << nbase);
    rts.resize(1 << nbase);
    for(ll i = 0; i < (1 << nbase); i++) {
      rev[i] = (rev[i >> 1] >> 1) + ((i & 1) << (nbase - 1));
    }
    assert(nbase <= max_base);
    while(base < nbase) {
      ll z = mod_pow(root, 1 << (max_base - 1 - base));
      for(ll i = 1 << (base - 1); i < (1 << base); i++) {
        rts[i << 1] = rts[i];
        rts[(i << 1) + 1] = mul(rts[i], z);
      }
      ++base;
    }
  }


  void ntt(vector< ll > &a) {
    const ll n = (ll) a.size();
    assert((n & (n - 1)) == 0);
    ll zeros = __builtin_ctzll(n);
    ensure_base(zeros);
    ll shift = base - zeros;
    for(ll i = 0; i < n; i++) {
      if(i < (rev[i] >> shift)) {
        swap(a[i], a[rev[i] >> shift]);
      }
    }
    for(ll k = 1; k < n; k <<= 1) {
      for(ll i = 0; i < n; i += 2 * k) {
        for(ll j = 0; j < k; j++) {
          ll z = mul(a[i + j + k], rts[j + k]);
          a[i + j + k] = add(a[i + j], mod - z);
          a[i + j] = add(a[i + j], z);
        }
      }
    }
  }


  vector< ll > multiply(vector< ll > a, vector< ll > b) {
    ll need = a.size() + b.size() - 1;
    ll nbase = 1;
    while((1 << nbase) < need) nbase++;
    ensure_base(nbase);
    ll sz = 1 << nbase;
    a.resize(sz, 0);
    b.resize(sz, 0);
    ntt(a);
    ntt(b);
    ll inv_sz = inverse(sz);
    for(ll i = 0; i < sz; i++) {
      a[i] = mul(a[i], mul(b[i], inv_sz));
    }
    reverse(a.begin() + 1, a.end());
    ntt(a);
    a.resize(need);
    return a;
  }
};
NumberTheoreticTransform<MOD> ntt;
////////////////////////////////////////////////////////////////////////////////
//vector<ll>a(2),b(3);
//rep(i,0,1)cin>>a[i];
//rep(i,0,2)cin>>b[i];
//auto c=ntt.multiply(a,b);
//for(auto x:c)cout<<x<<" ";cout<<endl;


ll po(ll i,ll p){
    if(p==0)return 1;
    else{
        i=mod(i);
        if(p==1)return i;
        if(p%2==0)return po(mod(i*i),p/2);
        return mod(i*po(i,p-1));
    }
}
ll bunbo(ll n){
    return po(n,i_5);
}

//from maspy
// https://atcoder.jp/contests/aising2020/submissions/15155062
ll coef_of_generating_function(vector<ll>P,vector<ll>Q,ll n){
    //多項式P,Qについて、PをQで割ったときのx^nの係数をreturn
    //Pの次数はQより小さいことが必要。
    
    for(auto &x:P)if(x<0)x=mod(x);
    for(auto &x:Q)if(x<0)x=mod(x);
    
    //Q[0]を1にする。
    ll z=Q[0];
    ll bz=bunbo(z);
    for(auto &x:P)x=mod(x*bz);
    for(auto &x:Q)x=mod(x*bz);
    
    ll sp=P.size(),sq=Q.size();
    
    rep(zz,1,sq-sp-1)P.pb(0);
    
    while(n>0){
        vector<ll>Q1(Q.size());
        rep(i,0,Q.size()-1){
            if(i%2==0){
                Q1[i]=Q[i];
            }else{
                Q1[i]=mod(-Q[i]);
            }
        }
        auto np=ntt.multiply(P,Q1);
        auto nq=ntt.multiply(Q,Q1);
        P.clear();Q.clear();
        for(ll i=n&1;i<=np.size()-1;i+=2)P.pb(np[i]);
        for(ll i=0;  i<=nq.size()-1;i+=2)Q.pb(nq[i]);
        n/=2;
    }
    return P[0];
}
///////////////////////

int main(){fastio
    ll n,m;cin>>n>>m;
    ll b[n+1];
    b[0]=-1;
    b[1]=-3;
    
    rep(i,2,n)b[i]=mod(3*b[i-1]-b[i-2]);
    ll c[n-1];
    if(n>=2){
        c[0]=1;
        if(n>=3){
            rep(i,0,n-3){
                c[0]=mod(c[0]*mod(m+n-3-i));
                c[0]=mod(c[0]*bunbo(n-2-i));
            }
            rep(i,1,n-2){
                c[i]=c[i-1];
                c[i]=mod(c[i]*(n-2-i+1));
                c[i]=mod(c[i]*bunbo(mod(m+n-3-i+1)));
            }
        }
    }
    ll ans=0;
    rep(i,0,n-2)Add(ans,b[i]*c[i]);
    vector<ll>A={mod(-b[n]+2*b[n-1]),mod(b[n]-3*b[n-1])};
    vector<ll>B={1,-1,-1};
    Add(ans,coef_of_generating_function(A, B, m-1));
    cout<<ans<<endl;
    /*
    rep(i,0,n)cout<<b[i]<<" ";cout<<endl;
    rep(i,0,n-2)cout<<c[i]<<" ";cout<<endl;
    cout<<coef_of_generating_function(A, B, m-1)<<endl;
    for(auto x:A)cout<<x<<" ";cout<<endl;
    */
    return 0;
}
