#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5, mod = 998244353;
int inv[maxn + 10], fac[maxn + 10], ifac[maxn + 10];
int pn[maxn + 10], pm[maxn + 10], ans;
int n, m;

void init() {
	fac[0] = ifac[0] = pn[0] = pm[0] = 1;
	for (int i = 1; i <= maxn; ++i) {
		fac[i] = 1ll * fac[i - 1] * i % mod;
		inv[i] = i == 1 ? 1 : mod - 1ll * (mod / i) * inv[mod % i] % mod;
		ifac[i] = 1ll * ifac[i - 1] * inv[i] % mod;
		pn[i] = 1ll * pn[i - 1] * (n + 1) % mod;
		pm[i] = 1ll * pm[i - 1] * (m + 1) % mod;
	}
}

inline int comb(int x, int y) {
	return 1ll * fac[x] * ifac[y] % mod * ifac[x - y] % mod;
}

int main() {
	scanf("%d%d", &n, &m);
	init();
	for (int i = 0; i <= n && i <= m; ++i) {
		int w = 1ll * comb(n, i) % mod * comb(m, i) % mod * fac[i] % mod;
		w = 1ll * w * pm[n - i] % mod * pn[m - i] % mod;
		if (i & 1) ans = (ans - w + mod) % mod;
		else (ans += w) %= mod;
	}
	printf("%d", ans);
}
