#include <bits/stdc++.h>
inline long long read() {
  long long res = 0, bo = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') bo = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    res = (res << 1) + (res << 3) + ch - '0';
    ch = getchar();
  }
  return bo * res;
}
template <typename T>
void read(T &x) {
  x = read();
}
template <typename T, typename... Argv>
void read(T &a, Argv &...argv) {
  read(a);
  read(argv...);
}
const long long N = 1e6 + 100, p = 998244353;
long long fac[N], inv[N], _n[N], _m[N];
long long mul(long long x, long long y) { return 1LL * x * y % p; }
long long ksm(long long x, long long y) {
  long long res = 1;
  for (; y; y >>= 1, x = mul(x, x))
    if (y & 1) res = mul(res, x);
  return res;
}
void init(long long n, long long m) {
  long long M = std::max(n, m);
  fac[0] = _n[0] = _m[0] = 1;
  for (long long i = 1; i <= M; ++i) fac[i] = mul(fac[i - 1], i);
  inv[n] = ksm(fac[n], p - 2);
  for (long long i = n; i >= 1; --i) inv[i - 1] = mul(inv[i], i);
  for (long long i = 1; i <= M; ++i) _n[i] = mul(_n[i - 1], n + 1);
  for (long long i = 1; i <= M; ++i) _m[i] = mul(_m[i - 1], m + 1);
}
long long C(long long n, long long m) {
  return mul(fac[n], mul(inv[m], inv[n - m]));
}
signed main() {
  long long n = read(), m = read(), ans = 0;
  init(n, m);
  for (long long i = 0, opt = 1; i <= std::min(n, m); ++i, opt = p - opt) {
    long long res =
        C(n, i) % p * C(m, i) % p * fac[i] % p * _m[n - i] % p * _n[m - i] % p;
    if (i & 1)
      ans = (ans - res + p) % p;
    else
      ans = (ans + res) % p;
  }
  std::cout << ans << std::endl;
  return 0;
}
