#include <bits/stdc++.h>
#define int long long

using namespace std;

const int P = 998244353;

const int N = 5e5+5;

int f[N];
int finv[N];

int nk[N];
int mk[N];

int n,m;

int qpow(int a, int b)
{
	int res = 1;
	while(b)
	{
		if(b%2)
			res = res*a %P;
		
		a = a*a %P;
		b /= 2; 
	}
	return res;
}

int getInv(int a)
{	
	return qpow(a,P-2);
}

void init()
{
	f[0] = 1;
	
	int t = max(n,m);
	
	for(int i = 1; i <= t; i++)
	{
		f[i] = (f[i-1]*i)%P;
	}
	finv[t] = getInv(f[t]) % P;

	for(int i = t; i > 0; i--)
	{
		finv[i-1] = finv[i]*i %P;
	}
	
	nk[0] = 1, mk[0] = 1;
	for(int i = 1; i <= t; i++)
	{
		nk[i] = nk[i-1]*(n+1) % P;
		mk[i] = mk[i-1]*(m+1) % P;
	}
}

int choose(int a, int b)
{
	int A = f[a]*finv[b] % P;
	int B = A*finv[a-b] % P;
	
	int res = B;

	return res; 
}

long long ans;

int cal(int k)
{
//	int res = (( (nk[m-k]*mk[n-k])%P * f[k])%P *(choose(n,k)*choose(m,k))%P) % P;
	
	int res;
	int A = nk[m-k]*mk[n-k]%P;
	int B = A*f[k] %P;
	int C = B*choose(n,k) %P;
	int D = C*choose(m,k) %P;
	res = D;
	
	if(k%2)
	{
		return -res;
	}
	else
	{
		return res;
	}
}

void debug()
{
	for(int i = 0; i <= max(n,m); i++)
	{
		printf("f[%lld]=%lld\n",i,f[i]);
	}
}

signed main()
{
	cin >> n >> m;
	
	init();
//	debug();
	
	for(int i = 0; i <= min(n,m); i++)
	{
		ans += cal(i);
		ans = (ans+P) %P;
//		printf("res[%lld]=%lld\n", i, cal(i));
	}
	
	cout << ans << endl;
	return 0;
}