#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define PLL pair<LL, LL>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define pb pop_back
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define Sim template<class n
Sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
Sim> auto operator << (ostream &p, n y) -> 
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
Sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
Sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
Sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " = ", (x), " "
#define A(a, i) #a "[" #i " = ", i, "] = ", a[i], " "
const int M = 1024 * 512;
const LL mod = 998244353;

int n, m;

LL sil[M], odw[M];

LL poww(LL x, LL e)
{
	if (e == 0)
	{
		return 1;
	}
	if (e % 2 == 0)
	{
		return poww(x * x % mod, e / 2);
	}
	return poww(x, e - 1) * x % mod;
}

LL newt(int a, int b)
{
	assert(b >= 0 && b <= a);
	LL res = sil[a] * odw[b] % mod;
	return res * odw[a - b] % mod;
}

int main()
{
	//ios_base::sync_with_stdio(0);
	//cin.tie(NULL);
	sil[0] = 1;
	odw[0] = 1;
	FOR(i, 1, M - 1)
	{
		sil[i] = sil[i - 1] * i % mod;
		odw[i] = poww(sil[i], mod - 2);
	}
	
	scanf("%d%d", &n, &m);
	LL res = 0;
	
	FOR(i, 0, min(n, m))
	{
		LL tmp = newt(n, i) * newt(m, i) % mod;
		tmp = tmp * sil[i] % mod;
		tmp = tmp * poww(m + 1, n - i) % mod;
		tmp = tmp * poww(n + 1, m - i) % mod;
		res = (res + poww(-1, i) * tmp + mod) % mod;
	}
	
	printf("%lld\n", res);
	return 0;
}

