#include #include #include using namespace std; using i32 = int32_t; using u32 = uint32_t; using i64 = int64_t; using u64 = uint64_t; #define rep(i,n) for(int i=0; i<(n); i++) // a^i mod M template u64 powm(u64 a,u64 i) { if(i == 0) return 1; u64 r = powm(a*a%MOD,i/2); if(i&1) r = r*a%MOD; return r; } template void NTT(vector& A){ int N=1; while(N < A.size()) N *= 2; for(int i=0,j=0; j>1; k>(i^=k); k>>=1); } for(int i=1; i(g,(MOD-1)/i/2), qj=1; for(int j=0; j= MOD) A[k] -= MOD; A[k+i] = l+MOD-r; if(A[k+i] >= MOD) A[k+i] -= MOD; } qj = qj * q % MOD; } } } template vector convolution(const vector& A, const vector& B){ int Z = 1; while(Z < A.size() + B.size()) Z *= 2; vector Ax(Z), Bx(Z); u64 iZ = powm(Z, MOD-2); rep(i, A.size()) Ax[i] = A[i]; rep(i, B.size()) Bx[i] = B[i]; NTT(Ax); NTT(Bx); rep(i,Z) Ax[i] = Ax[i] * Bx[i] % MOD; NTT(Ax); reverse(Ax.begin() + 1, Ax.end()); rep(i,Z) Ax[i] = Ax[i] * iZ % MOD; Ax.resize(A.size() + B.size() - 1); return move(Ax); } template vector powsumFPS(const vector& A, int n){ if(n == 0){ return {}; } if(n == 1){ return { 1 }; } int N = 1; while(N hInv = powsumFPS(A,hN); vector tgA(N,0); for(int i=0; i(g,MOD-2); NTT(tgA); vector htInv(N,0); for(int i=0; i(htInv); vector R(N); for(int i=0; i(R); reverse(R.begin()+1, R.end()); for(int i=0; i(R); u64 iNN = powm((u64)N*N%MOD,MOD-2); for(int i=0; i(R); reverse(R.begin()+1, R.end()); hInv.resize(n,0); for(int i=hN; i vector invFPS(const vector& A, int n){ u64 iA0 = powm(A[0],MOD-2); vector xA(min(n,(int)A.size())); for(int i=0; i(xA,n); for(int i=0; i InvMOD = {1,1}; template vector logFPS(const vector& A, int n){ int z = A.size(); for(int i=InvMOD.size(); i<=n; i++){ InvMOD.push_back((MOD - MOD/i) * InvMOD[MOD%i] % MOD); } auto res = invFPS(A, n); vector Abuf(z); rep(i,z-1) Abuf[i] = A[i+1] * (i+1) % MOD; res = convolution(res, Abuf); res.resize(n); for(int i=n-2; i>=0; i--) res[i+1] = res[i] * InvMOD[i+1] % MOD; res[0] = 0; return res; } template vector expFPS(const vector& A, int n){ vector res = {1}; while(res.size() < n){ int z = res.size(); auto tmp = logFPS(res,z*2); tmp[0] = MOD - 1; rep(i,min(z*2,A.size())){ tmp[i] = MOD - tmp[i] + A[i]; if(tmp[i] >= MOD) tmp[i] -= MOD; } res = convolution(res, tmp); res.resize(min(n,2*z)); } return res; } template vector powFPS(const vector& A, u64 k){ int n = A.size(); int zerocnt = 0; rep(i,n) if(A[i] == 0) zerocnt = i+1; else break; if(zerocnt >= (n-1)/k+1) return vector(n,0); auto res = A; rep(i,n-zerocnt) res[i] = res[i+zerocnt]; i64 A0 = res[0]; i64 iA0 = powm(A0,MOD-2); i64 pA0 = powm(A0,k); rep(i,n) res[i] = res[i] * iA0 % MOD; res = logFPS(res,n); rep(i,n) res[i] = res[i] * k % MOD; res = expFPS(res,n); rep(i,n) res[i] = res[i] * pA0 % MOD; zerocnt *= k; res.resize(n); for(int i=n-1; i>=zerocnt; i--) res[i] = res[i-zerocnt]; rep(i, zerocnt) res[i] = 0; return res; } const u64 MOD = 998244353; const u64 g = 3; int main(){ u64 x,y; cin >> x >> y; if(x > y) swap(x,y); vector G = convolution({1,2}, invFPS({1,MOD-1}, x+1)); G.resize(x+1); //for(auto g : G) cout << g << " "; cout << endl; auto B = powFPS(G, y); rep(i,x) B[i+1] = (B[i+1] + B[i]) % MOD; //for(auto g : B) cout << g << " "; cout << endl; auto G2 = invFPS(G, x+1); reverse(G2.begin(), G2.end()); G2.push_back(0); reverse(G2.begin(), G2.end()); B = convolution(B, powsumFPS(G2, x+1)); u64 ans = B[x]; cout << ans << endl; return 0; } struct ios_do_not_sync { ios_do_not_sync() { ios::sync_with_stdio(false); cin.tie(nullptr); } } ios_do_not_sync_instance;