#include<iostream>
#define int long long
const int N=5e5+2;
const int mod=998244353;
using namespace std;
int fact[N],inv[N],pn[N],pm[N];
int binpow(int x,int y){
	int tich=1;
	while(y){
		if(y&1){
			tich*=x;
			tich%=mod;
		}
		x*=x;
		x%=mod;
		y>>=1;
	}
	return tich;
}
int C(int x,int y){
	return (fact[y]*((inv[x]*inv[y-x])%mod))%mod;
}
signed main(){
	int n,m,i,j=1,ans=0;
	cin>>n>>m;
	fact[0]=1;
	pn[0]=1;
	pm[0]=1;
	for(i=1;i<=max(n,m);i++){
		pn[i]=(pn[i-1]*(n+1))%mod;
		pm[i]=(pm[i-1]*(m+1))%mod;
		fact[i]=(fact[i-1]*i)%mod;
//		cout<<fact[i]<<endl;
	}
	inv[max(n,m)]=binpow(fact[max(n,m)],mod-2);
	for(i=max(n,m);i>=1;i--){
		inv[i-1]=(inv[i]*i)%mod;
//		cout<<inv[i]<<endl;
	}
	for(i=0;i<=min(n,m);i++){
		ans+=j*((((C(i,n)*C(i,m))%mod)*((fact[i]*pn[m-i])%mod))%mod)*pm[n-i];
		ans%=mod;
		if(ans<0){
			ans+=mod;
		}
		j*=-1;
//		cout<<i<<' '<<ans<<endl;
	}
	cout<<ans;
}