#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
int A, B, C, D;
lint dp[3003][3003];
const lint MOD = 998244353;
void modAdd(lint& a, lint b) { a = (a + b) % MOD; }
int main() {
  cin >> A >> B >> C >> D;
  memset(dp, 0, sizeof(dp));
  dp[A][B] = 1;
  for (int i = A + 1; i < C + 1; ++i) modAdd(dp[i][B], dp[i - 1][B] * B);
  for (int j = B + 1; j < D + 1; ++j) modAdd(dp[A][j], dp[A][j - 1] * A);
  for (int i = A + 1; i < C + 1; ++i)
    for (int j = B + 1; j < D + 1; ++j) {
      lint x = (dp[i][j - 1] * i) % MOD;
      lint y = (dp[i - 1][j] * j) % MOD;
      lint z = (dp[i - 1][j - 1] * (i - 1) * (j - 1)) % MOD;
      lint add = (x + y - z + MOD) % MOD;
      modAdd(dp[i][j], add);
    }
  cout << dp[C][D] << endl;
}
