#include <bits/stdc++.h>
void err() { std::cout << '\n'; }
template <typename T, typename... Args>
void err(T a, Args... args) {
  std::cout << a << ' ';
  err(args...);
}
template <template <typename...> class T, typename t, typename... A>
void err(const T<t> &arg, const A &...args) {
  for (auto &v : arg) std::cout << v << ' ';
  err(args...);
}
using namespace std;
const int N = 1e5 + 5, MOD = 998244353, inv2 = (MOD + 1) >> 1;
int qpow(long long a, long long b) {
  long long res = 1;
  a %= MOD;
  while (b) {
    if (b & 1) res = res * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return res;
}
void run() {
  long long n, m, L, R;
  cin >> n >> m >> L >> R;
  int even = R / 2, odd = (R + 1) / 2;
  even -= (L - 1) / 2, odd -= L / 2;
  int res = qpow(even + odd, n * m);
  if ((n * m) & 1)
    cout << res << '\n';
  else {
    res += qpow(max(even, odd) - min(even, odd), n * m);
    res %= MOD;
    res = 1ll * res * inv2 % MOD;
    cout << res << '\n';
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(20);
  run();
  return 0;
}
