#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
long long qpow(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = res * a % mod;
    b >>= 1;
    a = a * a % mod;
  }
  return res;
}
int main(int argc, const char *argv[]) {
  int n, m, L, R;
  cin >> n >> m >> L >> R;
  int odd = (R - L + 1) / 2, even = (R - L + 1) / 2;
  if ((R - L + 1) % 2) {
    if (L % 2)
      odd++;
    else
      even++;
  }
  long long all = qpow(R - L + 1, 1ll * n * m);
  if (1ll * n * m % 2)
    cout << all << endl;
  else
    cout << (all + (even == odd ? 0 : 1)) * qpow(2, mod - 2) % mod << endl;
  return 0;
}
