#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 998244353;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

ll mpow(ll x, ll n){ //x^n(mod mo) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mo;
        x = x*x % mo;
        n = n >> 1;
    }
    return ans;
}
 
const int mod = 998244353;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
 
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};
mint dp[3010][3010][3];
int main(){
    ll A,B,C,D;
    cin >> A >> B >> C >> D;
    //vector<vector<mint>> dp(3010, vector<mint>(3010));
    dp[A][B][0] = 1;
    /*
    for(ll i=A;i<C;i++){
        dp[i+1][B] += dp[i][B]*B;
    }
    for(ll j=B;j<D;j++){
        dp[A][j+1] += dp[A][j]*A;
    }
    dp[A+1][B+1] = dp[A][B+1]*(B+1) + dp[A+1][B];
    *//*
    REP(k,0,100){
        for(ll i=A+k;i<C;i++){
            dp[i+1][B+k] += dp[i][B+k]*(B+k);
        }
        for(ll j=B+k;j<D;j++){
            dp[A+k][j+1] += dp[A+k][j]*(A+k);
        }
        dp[A+k+1][B+k+1] = dp[A+k][B+k+1]*(B+k+1) + dp[A+k+1][B+k];
    }*/
    rep(i,C-A){
        dp[A+i+1][B][1] += dp[A+i][B][0]*B + dp[A+i][B][1]*B + dp[A+i][B][2]*B;
    }
    rep(i,D-B){
        dp[A][B+i+1][0] += dp[A][B+i][0]*(A-1);
        dp[A][B+i+1][1] += dp[A][B+i][0] + dp[A][B+i][1]*(A-1);
        dp[A][B+i+1][2] += dp[A][B+i][1] + dp[A][B+i][2]*A;
    }
    rep(i,C-A){
        rep(j,D-B){
            //dp[A+i+1][B+j+1] += dp[A+i][B+j];
            dp[A+i+1][B+j+1][0] += dp[A+i+1][B+j][0]*(A+i);

            //dp[A+i+1][B+j+1][1] += dp[A+i+1][B+j][0] + dp[A+i+1][B+j][1]*(A+i);
            dp[A+i+1][B+j+1][1] += dp[A+i][B+j+1][0]*(B+j+1) + dp[A+i][B+j+1][1]*(B+j+1) + dp[A+i][B+j+1][2]*(B+j+1);
            
            dp[A+i+1][B+j+1][2] += dp[A+i+1][B+j][1] + dp[A+i+1][B+j][2]*(A+i+1);
        }
    }
    /*
    REP(k,0,100){
        dp[A+k+1][B+k+1] += dp[A+k][B+k+1]*(B+k+1) + dp[A+k+1][B+k];

        rep(i,C-A-k){
            dp[A+k+i+2][B+k+1] += dp[A+k+1+i][B+k+1]*(B+k+1);
        }
        rep(i,D-B-k){
            dp[A+k+1][B+k+i+2] += dp[A+k+1][B+k+1+i]*(A+k+1);
        }
    }
    /*rep(k,10){
        cout << dp[A+k][B+k] << endl;
    }/*
    if(C <= D){
        ll t = C - A;
        for(ll k=B+C-A;k<D;k++){
            dp[C][k+1] = (dp[C][k]*C)%mo;
        }
    }else{
        for(ll k=A+D-B;k<C;k++){
            dp[k+1][D] += (dp[k][D]*D)%mo;
        }
    }*/
    //cout << dp[C-1][D-1] << endl;
    //cout << dp[C-1][D] << endl;
    /*cout << "2 4 " << dp[2][4] << endl;
    cout << "3 3 " << dp[3][3] << endl;
    cout << "3 2 " << dp[3][2] << endl;
    cout << "2 3 " << dp[2][3] << endl;*/
    //cout << dp[1][2][0] << dp[1][2][1] << dp[1][2][2] << endl;
    //cout << dp[2][1][0] << dp[2][1][1] << dp[2][1][2] << endl;
    //cout << dp[C][D][0] << dp[C][D][1] << dp[C][D][2] << endl;
    cout << dp[C][D][0] + dp[C][D][1] + dp[C][D][2] << endl;
}


Measured memory_bytes: 215952