#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;

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[3002][3002][3];
int main(){
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    dp[A][B][0] = 1;
    REP(i,A,C){
        dp[i+1][B][1] = dp[i][B][0]*B + dp[i][B][1]*B + dp[i][B][2]*B; 
    }
    REP(i,B,D){
        dp[A][i+1][0] = dp[A][i][0]*(A-1);// + dp[A][i][1]*(A-1); 
        dp[A][i+1][1] = dp[A][i][0] + dp[A][i][1]*(A-1); 
        dp[A][i+1][2] = dp[A][i][1] + dp[A][i][2]*(A); 
    }
    REP(i,A,C){
        REP(j,B,D){
            dp[i+1][j+1][0] += dp[i+1][j][0]*i;
            //dp[i+1][j+1][1] = dp[i+1][j][0] + dp[i+1][j][1]*(i) + dp[i][j+1][]*j;
            dp[i+1][j+1][2] += dp[i+1][j][1] + dp[i+1][j][2]*(i+1);
            dp[i+1][j+1][1] += dp[i][j+1][0]*(j+1) + dp[i][j+1][1]*(j+1) + dp[i][j+1][2]*(j+1);
            //dp[i+1][j][2] += dp[i][j][1]*j + dp[i][j][2]*j;
            //dp[i][j+1][0] += dp[i][j][0] * (i-1) + dp[i][j][1] * (i-1);
            //dp[i][j+1][1] += dp[i][j][0] + dp[i][j][1];
            //dp[i+1][j][0] += dp[i][j][0] * (j-1) + dp[i][j][1] * (j-1);
            //dp[i+1][j][0] += dp[i][j][1] * (j-1);
            //dp[i+1][j][1] += dp[i][j][0] + dp[i][j][1];
        }
    }
    /*
    cout << dp[1][1][0] << " " << dp[1][1][1] << endl;
    cout << dp[1][2][0] << " " << dp[1][2][1]<< endl;
    cout << dp[2][1][0] << " " << dp[2][1][1]<< endl;
    cout << dp[2][2][0] << " " << dp[2][2][1]<< endl;/*
    cout << dp[2][2][0] << " " << dp[2][2][1] << endl;
    cout << dp[2][3][0] << " " << dp[2][3][1]<< endl;
    cout << dp[3][2][0] << " " << dp[3][2][1]<< endl;
    cout << dp[3][3][0] << " " << dp[3][3][1]<< endl;*/
    cout << dp[C][D][0] + dp[C][D][1] + dp[C][D][2]<< endl;
}

Measured memory_bytes: 214796