#include <bits/stdc++.h>
using namespace std;
using ll = long long;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  const int MOD = 998244353;
  auto binpow = [&](ll a, ll p) {
    a %= MOD;
    ll res = 1;
    for (; p; a = a * a % MOD, p >>= 1)
      if (p & 1) res = res * a % MOD;
    return res;
  };
  auto rev = [&](ll a) { return binpow(a, MOD - 2); };
  ll n, m, L, R;
  while (cin >> n >> m >> L >> R) {
    if (n * m % 2) {
      cout << binpow(R - L + 1, n * m);
    } else {
      ll u = 0, v = 0;
      if (L % 2 == 0) ++v, ++L;
      if (R % 2) ++u, --R;
      u += (R - L + 1) / 2;
      v += (R - L + 1) / 2;
      if (u < v) swap(u, v);
      ll t1 = binpow(u + v, n * m);
      ll t2 = binpow(u - v, n * m);
      ll res = (t1 + t2) % MOD * rev(2) % MOD;
      cout << res;
    }
    cout << "\n";
  }
}
