#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> prl;
typedef vector<ll> vcl;
typedef map<ll,ll> mapl;
typedef unordered_map<ll,ll> umap;
#define pb push_back
#define all(v) v.begin(), v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repi(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 998244353;

//Power
ll powmod(ll px, ll py, ll pmod){
	if(py == 0) return 1;
	if(py % 2 == 0) return powmod((px * px) % pmod, py / 2, pmod);
	else return (px * powmod(px, py - 1, pmod)) % pmod;
} 

const ll c_max = 1e6+5;
ll fac[c_max], finv[c_max], inv[c_max];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    rep(i,2,c_max-1){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
ll COM(ll comn, ll comk){
    if (comn < comk) return 0;
    if (comn < 0 || comk < 0) return 0;
    if (comn >= c_max){
        ll cret = finv[comk];
        rep(i,0,comk-1) cret = (cret * (comn - i)) % mod;
        return cret;
    }
    return fac[comn] * (finv[comk] * finv[comn - comk] % mod) % mod;
}

//Extended_GCD
ll extgcd(ll a, ll b, ll &x, ll &y){
	ll mgcd_ = a;
	if (b != 0){
		mgcd_ = extgcd(b, a % b, y ,x);
		y -= (a/b) * x;
	} else {
   		x = 1;
   		y = 0;
   	}
   	return mgcd_;
}
//Inverse
ll Inv(ll a, ll b){
   	ll x, y;
   	extgcd(a, b, x, y);
   	if(x >= 0) return x % b;
   	else return (b - (-x) % b) % b;
}

int main() {
    COMinit();
    // your code goes here
    ll a,b,c,d,dp[3005][3005]={0},ans=0,tr[3005][3005]={0},rui[3005][3005]={0},pa,sd;
    cin >> a >> b >> c >> d;
    if(a==c&&b==d){
        cout << 1 << endl;
    } else if(a==c){
        cout << powmod(a,d-b,mod) << endl;
    } else if(b==d){
        cout << powmod(b,c-a,mod) << endl;
    } else {
        rep(i,a+1,c){
            if(i==a+1){
                rep(j,1,d){
                    dp[i][j]=powmod(a,d-b,mod)*powmod(i*inv[i-1]%mod,min(d-b,d-j),mod)%mod;
                }
                rep(j,1,d){
                    rui[i][j]=(rui[i][j-1]+dp[i][j])%mod;
                }
                continue;
            }
            rep(j,1,d){
                pa=i*inv[i-1]%mod;
                if(j<=b){
                    dp[i][j]=(dp[i][j]+(dp[i-1][j]*powmod(pa,d-b,mod)%mod)*j%mod)%mod;
                    dp[i][j]=(dp[i][j]+(rui[i-1][j-1]*powmod(pa,d-b,mod)%mod)%mod)%mod;
                } else {
                    dp[i][j]=(dp[i][j]+(dp[i-1][j]*powmod(pa,d-j,mod)%mod)*j%mod)%mod;
                    dp[i][j]=(dp[i][j]+(rui[i-1][j-1]*powmod(pa,d-j,mod)%mod)%mod)%mod;
                }
            }
            rep(j,1,d){
                rui[i][j]=(rui[i][j-1]+dp[i][j])%mod;
            }
        }
        rep(i,1,d){
            ans=(ans+dp[c][i])%mod;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 168172