#include <bits/stdc++.h>
using namespace std;
long long int mod = 998244353;
pair<long long int, long long int> za(pair<long long int, long long int> p1,
                                      pair<long long int, long long int> p2) {
  pair<long long int, long long int> ret = make_pair(
      (((p1.first * p2.second) % mod) + ((p1.second * p2.first) % mod)) % mod,
      (((p1.first * p2.first) % mod) + ((p1.second * p2.second) % mod)) % mod);
  return ret;
}
pair<long long int, long long int> wop(long long int t, long long int l,
                                       long long int r) {
  pair<long long int, long long int> ret = make_pair(0, 0), ba;
  if (l & 1) {
    ba.first = (r - l + 2) / 2;
    ba.second = r - l + 1 - ba.first;
  } else {
    ba.second = (r - l + 2) / 2;
    ba.first = r - l + 1 - ba.second;
  }
  bool fi = 0;
  for (; t >= 1; t /= 2) {
    if (t & 1) {
      if (fi)
        ret = za(ret, ba);
      else {
        fi = 1;
        ret = ba;
      }
    }
    ba = za(ba, ba);
  }
  return ret;
}
long long int power(long long int x, long long int y) {
  long long int ret = 1;
  for (; y >= 1; y /= 2) {
    if (y & 1) ret *= x;
    x *= x;
    ret %= mod;
    x %= mod;
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(0);
  long long int n, m, l, r;
  cin >> n >> m >> l >> r;
  if (n & m & 1) return cout << power(r - l + 1, n * m), 0;
  long long int mn = m * n;
  pair<long long int, long long int> p = wop(mn / 2, l, r),
                                     p2 = wop((mn + 1) / 2, l, r);
  long long int fa;
  if (l & 1)
    fa = (r - l + 2) / 2;
  else
    fa = r - l + 1 - ((r - l + 2) / 2);
  cout << za(p, p2).second << '\n';
}
