#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char p = getchar();
  while (!isdigit(p)) {
    if (p == '-') f = -1;
    p = getchar();
  }
  while (isdigit(p)) x = (x << 3) + (x << 1) + (p ^ 48), p = getchar();
  return x * f;
}
const long long mod = 998244353;
long long ans, n, m, L, R, jishu, oushu, bl, wt, wtj, wto, blj, blo;
inline long long power(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return ans;
}
signed main() {
  n = read();
  m = read();
  L = read();
  R = read();
  if (n * m & 1) {
    cout << power(R - L + 1, n * m) << endl;
    return 0;
  }
  if ((R - L + 1) & 1) {
    jishu = (R - L) >> 1;
    oushu = (R - L) >> 1;
    if (R & 1)
      jishu++;
    else
      oushu++;
  } else
    jishu = oushu = (R - L + 1) >> 1;
  wt = (n * m) / 2;
  bl = n * m - wt;
  long long sum1 = power(jishu + oushu, wt);
  long long sum2 = power((jishu - oushu + mod) % mod, wt);
  long long sum3 = ((sum1 - sum2 + mod) % mod) * power(2, mod - 2) % mod;
  long long sum4 = (sum1 - sum3 + mod) % mod;
  if (wt & 1)
    wto = sum4, wtj = sum3;
  else
    wto = sum3, wtj = sum4;
  sum1 = power(jishu + oushu, bl);
  sum2 = power((jishu - oushu + mod) % mod, bl);
  sum3 = ((sum1 - sum2 + mod) % mod) * power(2, mod - 2) % mod;
  sum4 = (sum1 - sum3 + mod) % mod;
  if (bl & 1)
    blo = sum4, blj = sum3;
  else
    blo = sum3, blj = sum4;
  ans = (wtj * blj % mod + wto * blo % mod) % mod;
  cout << ans << endl;
  return 0;
}
