#include<iostream>
#include<cstdio>

int n,m;
const int mod=998244353;
int powM[500050],powN[500050],fact[500050],ifact[500050];

inline int pow(int a,int b){
	int ret=1;
	for (;b;b>>=1,a=static_cast<long long>(a)*a%mod)
		if (b&1) ret=static_cast<long long>(ret)*a%mod;
	return ret;
}

int ans;

int main(){
	scanf("%d%d",&n,&m);
	powM[0]=1,powN[0]=1;
	for (int i=1;i<=n;i++) powM[i]=powM[i-1]*(m+1LL)%mod;
	for (int i=1;i<=m;i++) powN[i]=powN[i-1]*(n+1LL)%mod;
	fact[0]=1;
	for (int i=1;i<=n||i<=m;i++) fact[i]=static_cast<long long>(fact[i-1])*i%mod;
	ifact[std::max(n,m)]=pow(fact[std::max(n,m)],mod-2);
	for (int i=std::max(n,m);i;i--) ifact[i-1]=static_cast<long long>(ifact[i])*i%mod;
	for (int i=0;i<=n&&i<=m;i++){
		if (i&1) ans=(ans-static_cast<long long>(ifact[i])*ifact[n-i]%mod*ifact[m-i]%mod*powM[n-i]%mod*powN[m-i]%mod+mod)%mod;
		else ans=(ans+static_cast<long long>(ifact[i])*ifact[n-i]%mod*ifact[m-i]%mod*powM[n-i]%mod*powN[m-i]%mod+mod)%mod;
	}
	printf("%lld\n",static_cast<long long>(ans)*fact[n]%mod*fact[m]%mod);
}
