#include<algorithm>
#include<cstdio>
#define mxn 500010
#define LL long long
#define mod 998244353
using namespace std;
LL fac[mxn],ifc[mxn];
int n,m,sl,fh,ans;
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
LL C(int x,int y) {return fac[x]*ifc[y]%mod*ifc[x-y]%mod;}
LL _pow(LL k,int i)
{
	static LL t;t=1;
	for(;i;i>>=1,k=k*k%mod)
		if(i&1)
			t=t*k%mod;
	return t;
}
int main()
{
	n=rd();m=rd();if(n>m) swap(n,m);fac[0]=1;
	for(int i=1;i<=m;++i) fac[i]=i*fac[i-1]%mod;
	ifc[m]=_pow(fac[m],mod-2);
	for(int i=m;i;--i) ifc[i-1]=i*ifc[i]%mod;
	for(int i=0,c=1;i<=n;++i,c=mod-c) ans=(ans+c*C(n,i)%mod*C(m,i)%mod*fac[i]%mod*_pow(m+1,n-i)%mod*_pow(n+1,m-i))%mod;
	printf("%d\n",ans);
	return 0;
}