#pragma GCC optimize (2)
#pragma G++ optimize (2)
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define mod 998244353
#define MAX 500005
using namespace std;
//char nc()
//{
//	static char buf[100000],*p1=buf,*p2=buf;
//	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
char nc(){return getchar();}
int read()
{
	int x=0,y=1;
	char c=nc();
	while(!isdigit(c))
	{
		if(c=='-')y=-1;
		c=nc();
	}
	while(isdigit(c))
	{
		x=(x<<1)+(x<<3)+(c^48);
		c=nc();
	}
	return x*y;
}
int n,m;
long long fac[MAX],facinv[MAX],pwn1[MAX],pwm1[MAX];
long long mo(long long x)
{
	return x<mod?x:x-mod;
}
long long quick_pow(long long x,long long y)
{
	long long re=1;
	while(y)
	{
		if(y&1) re=re*x%mod;
		x=x*x%mod;
		y>>=1;
	}
	return re;
}
long long C(long long down,long long up)
{
	return fac[down]*facinv[down-up]%mod*facinv[up]%mod;
}
int main()
{
	n=read();m=read();
	int up=max(n,m);
	fac[0]=1;
	for(int i=1;i<=up;i++)
		fac[i]=fac[i-1]*i%mod;
	facinv[up]=quick_pow(fac[up],mod-2);
	for(int i=up;i;i--)
		facinv[i-1]=facinv[i]*i%mod;
	pwn1[0]=1;
	for(int i=1;i<=m;i++)
		pwn1[i]=pwn1[i-1]*(n+1)%mod;
	pwm1[0]=1;
	for(int i=1;i<=n;i++)
		pwm1[i]=pwm1[i-1]*(m+1)%mod;
	long long ANS=0;
	for(int i=0;i<=min(n,m);i++)
		if(!(i&1)) ANS=(ANS+C(n,i)*C(m,i)%mod*fac[i]%mod*pwm1[n-i]%mod*pwn1[m-i])%mod;
		else ANS=mo(ANS-C(n,i)*C(m,i)%mod*fac[i]%mod*pwm1[n-i]%mod*pwn1[m-i]%mod+mod);
	printf("%lld",ANS);
	return 0;
}