#include <algorithm>
#include <array>
#include <assert.h>
#include <bitset>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>

#include <istream>
#include <map>
#include <math.h>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

namespace asl
{
    
    const int m1000000007 = 1000000007;
    
    const int m998244353 = 998244353;

    int MOD = m1000000007;

    void set_mod(int mod)
    {
        MOD = mod;
    }

    class Mint
    {
    public:
        int val;

        Mint(long long v = 0)
        {
            if (v >= 0)
            {
                if (v < MOD)
                    val = v;
                else
                    val = v % MOD;
            }
            else
            {
                if (v >= -MOD)
                {
                    val = v + MOD;
                }
                else
                {
                    v %= MOD;
                    if (v < 0)
                        v += MOD;
                    val = v;
                }
            }
        }

        Mint &operator+=(const Mint &other)
        {
            val += other.val;
            if (val >= MOD)
                val -= MOD;
            return *this;
        }

        Mint &operator-=(const Mint &other)
        {
            val -= other.val;
            if (val < 0)
                val += MOD;
            return *this;
        }

        static unsigned fast_mod(uint64_t x, unsigned m = MOD)
        {
#if !defined(_WIN32) || defined(_WIN64)
            return x % m;
#endif
            
            unsigned x_high = x >> 32, x_low = (unsigned)x;
            unsigned quot, rem;
            asm("divl %4\n"
                : "=a"(quot), "=d"(rem)
                : "d"(x_high), "a"(x_low), "r"(m));
            return rem;
        }

        Mint &operator*=(const Mint &other)
        {
            val = fast_mod((uint64_t)val * other.val);
            return *this;
        }

        friend Mint operator+(const Mint &a, const Mint &b) { return Mint(a) += b; }
        friend Mint operator-(const Mint &a, const Mint &b) { return Mint(a) -= b; }
        friend Mint operator*(const Mint &a, const Mint &b) { return Mint(a) *= b; }
        
        friend std::ostream &operator<<(std::ostream &stream, const Mint &m)
        {
            return stream << m.val;
        }

    };
} 

#include <random>

#define endl '\n'

using namespace std;
using namespace asl;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    set_mod(m998244353);

    int A, B, C, D;
    cin >> A >> B >> C >> D;

    vector<Mint> dp(D + 1, 1);
    for (int d = B + 1; d <= D; ++d)
    {
        dp[d] = dp[d - 1] * A;
    }

    for (int c = A + 1; c <= C; ++c)
    {
        vector<Mint> ndp(D + 1);

        ndp[B] = dp[B] * B;

        for (int d = B + 1; d <= D; ++d)
        {
            ndp[d] = ndp[d - 1] + dp[d] + ndp[d - 1] * (c - 1) + dp[d] * (d - 1) - dp[d - 1] * (c - 1) * (d - 1);
        }

        dp.swap(ndp);
    }

    cout << dp.back() << endl;

    return 0;
}




Measured memory_bytes: 3192