#include <bits/stdc++.h>
using namespace std;
const int Maxn=500005,mod=998244353;
int fac[Maxn],ifac[Maxn];
int ksm(int x,int k){
    int ret=1,tmp=x;
    while(k){
        if(k&1)ret=1ll*ret*tmp%mod;
        tmp=1ll*tmp*tmp%mod;k>>=1;
    }
    return ret;
}
int inv(int x){return ksm(x,mod-2);}
int C(int n,int m){return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;}
int main(){
    for(int i=fac[0]=1;i<Maxn;i++)fac[i]=1ll*fac[i-1]*i%mod;
    for(int i=0;i<Maxn;i++)ifac[i]=inv(fac[i]);
    int n,m,ans=0;cin>>n>>m;
    for(int i=0,w=1;i<=min(n,m);i++,w*=-1)
        ans=(ans+1ll*w*C(n,i)*C(m,i)%mod*fac[i]%mod*ksm(m+1,n-i)%mod*ksm(n+1,m-i))%mod;
    cout<<(ans+mod)%mod<<"\n";
    return 0;
}