#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long hxtype;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const int N=500005;
const ll p=998244353ll;
ll fa[N],ia[N];
inline ll expo(ll a,int b=998244351){
	ll c=1ll;
	while(b){
		if(b&1)c=c*a%p;
		b>>=1; a=a*a%p;
	}
	return c;
}
int main(){
	int n,m,i;ll ans=0ll,tmp;
	scanf("%d%d",&n,&m);
	if(n>m)swap(n,m);
	fa[0]=1ll;
	rep(i,1,m)fa[i  ]=fa[i-1]*i%p;
	ia[m]=expo(fa[m]);
	per(i,m,1)ia[i-1]=ia[i  ]*i%p;
	rep(i,0,n){
		tmp=ia[i];
		tmp=tmp*(fa[n]*ia[n-i]%p)%p;
		tmp=tmp*(fa[m]*ia[m-i]%p)%p;
		tmp=tmp*(expo(m+1,n-i)*expo(n+1,m-i)%p)%p;
		if(i&1)ans-=tmp;else ans+=tmp;
	}
	printf("%lld",(ans+p*p)%p);
	return 0;
}