#include<cstdio>
#include<algorithm>
using namespace std;
const int N=5e5+5;
const int mod=998244353;
int n,m,inv[N],jc[N],jcn[N],pn[N],pm[N],ans;
int C(int n,int m){return 1ll*jc[n]*jcn[m]%mod*jcn[n-m]%mod;}
int main(){
	scanf("%d%d",&n,&m);
	if(n<m)swap(n,m);
	inv[1]=jc[0]=jcn[0]=1;
	for(int i=2;i<=n;++i)inv[i]=1ll*inv[mod%i]*(mod-mod/i)%mod;
	for(int i=1;i<=n;++i){
		jc[i]=1ll*jc[i-1]*i%mod;
		jcn[i]=1ll*jcn[i-1]*inv[i]%mod;
	}
	for(int i=pn[0]=1;i<=m;++i)pn[i]=1ll*pn[i-1]*(n+1)%mod;
	for(int i=pm[0]=1;i<=n;++i)pm[i]=1ll*pm[i-1]*(m+1)%mod;
	for(int i=0;i<=m;++i){
		int res=1ll*C(n,i)*C(m,i)%mod*jc[i]%mod*pn[m-i]%mod*pm[n-i]%mod;
		i&1?ans=(ans-res+mod)%mod:ans=(ans+res)%mod;
	}
	printf("%d\n",ans);
	return 0;
}
