#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
using namespace std;
template <typename T>
void debugv(vector<T> a) {
  for (auto i : a) {
    cout << i << " ";
  }
  cout << '\n';
  return;
  return;
}
void logg(string s) { cout << s << '\n'; }
template <class T>
inline bool remax(T &a, T b) {
  return a < b ? a = b, 1 : 0;
}
template <class T>
inline bool remin(T &a, T b) {
  return a > b ? a = b, 1 : 0;
}
long long md = 998244353;
long long fact[1003], mi[1003];
long long my_gcd(long long n, long long m) {
  if (n % m == 0) return m;
  if (n < m) swap(n, m);
  while (m > 0) {
    n = n % m;
    swap(n, m);
  }
  return n;
}
long long pw(long long a, long long b) {
  long long c = 1, m = a % md;
  while (b) {
    if (b & 1) c = (c * m) % md;
    m = (m * m) % md;
    b /= 2;
  }
  return c;
}
long long modinv(long long n) { return pw(n, md - 2); }
inline long long add(long long a, long long b) {
  return (md + a % md + b % md) % md;
}
inline long long subt(long long a, long long b) {
  return (a % md - b % md + md) % md;
}
inline long long mult(long long a, long long b) {
  return (1ll * (a % md) * (b % md)) % md;
}
long long ncr(int n, int r) {
  if (!n) return 1;
  return mult(fact[n], mult(mi[r], mi[n - r]));
}
void pre() {
  fact[0] = 1;
  long long lim = 1003;
  for (long long i = 1; i < lim; i++) fact[i] = mult(i, fact[i - 1]);
  for (long long i = 0; i < lim; i++) mi[i] = modinv(fact[i]);
}
int myceil(int a, int b) {
  if (a % b)
    return (a / b) + 1;
  else
    return a / b;
};
int cnt;
int mx;
int vis[(1 << (20))];
void rec(int n, int p) {
  if (vis[n]) return;
  vis[n] = 1;
  cnt++;
  for (long long i = 0; i < 20; i++) {
    if ((1 << (i)) > mx) break;
    int t1 = n;
    t1 = t1 ^ (1 << (i + 1));
    if (t1 > mx) t1 = n;
    if (i) {
      t1 = t1 ^ (1 << (i - 1));
    }
    if (t1 > mx) t1 = n;
    if (t1 == n) break;
    rec(t1, n);
  }
  return;
}
void solvetestcase(long long tcn) {
  long long n, m, l, r;
  cin >> n >> m >> l >> r;
  long long tot = n * m;
  long long e = r / 2 - (l - 1) / 2;
  long long o = (r - l + 1) - e;
  long long ans = pw((e + o) % md, tot);
  if (tot % 2) {
    cout << ans;
    return;
  }
  long long inval =
      mult(subt(pw((e + o) % md, tot), pw(llabs(e - o) % md, tot)), modinv(2));
  ans = subt(ans, inval);
  cout << ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1;
  for (long long i = 1; i < t + 1; i++) {
    solvetestcase(i);
  }
  return 0;
};
