#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &t) {
  t = 0;
  char ch = getchar();
  int f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  do {
    (t *= 10) += ch - '0';
    ch = getchar();
  } while ('0' <= ch && ch <= '9');
  t *= f;
}
const long long mod = 998244353;
long long ksm(long long x, long long y) {
  if (x < 0) x += mod;
  if (x >= mod) x -= mod;
  long long res = 1;
  while (y) {
    if (y & 1) res = res * x % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return res;
}
long long n, m, N, L, R, ans, x, y;
int main() {
  read(n);
  read(m);
  read(L);
  read(R);
  N = n * m;
  x = R / 2 - (L - 1) / 2;
  y = R - L + 1 - x;
  if (N % 2 == 1)
    ans = ksm(x + y, N);
  else {
    ans = ksm(x + y, N) + ksm(x - y, N);
    ans %= mod;
    if (N % 2 == 0) ans = ans * ksm(2, mod - 2) % mod;
  }
  printf("%lld\n", ans);
  return 0;
}
