#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
array<array<long long, 2>, 2> mult(array<array<long long, 2>, 2> first,
                                   array<array<long long, 2>, 2> second) {
  array<array<long long, 2>, 2> res;
  res[0][0] = res[1][1] = 0;
  res[0][1] = res[1][0] = 0;
  for (long long i = 0; i < 2; i++)
    for (long long j = 0; j < 2; j++)
      for (long long t = 0; t < 2; t++) res[i][t] += first[i][j] * second[j][t];
  for (long long i = 0; i < 2; i++)
    for (long long j = 0; j < 2; j++) res[i][j] %= MOD;
  return res;
}
array<array<long long, 2>, 2> ppow(array<array<long long, 2>, 2> first,
                                   long long second) {
  array<array<long long, 2>, 2> res;
  res[0][0] = res[1][1] = 1;
  res[0][1] = res[1][0] = 0;
  while (second) {
    if (second & 1) res = mult(res, first);
    second >>= 1;
    first = mult(first, first);
  }
  return res;
}
long long ppow(long long first, long long second) {
  long long res = 1;
  while (second) {
    if (second & 1) res = res * first % MOD;
    second >>= 1;
    first = first * first % MOD;
    ;
  }
  return res;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m, l, r;
  cin >> n >> m >> l >> r;
  long long s = n * m, k = r - l + 1;
  long long d, e;
  if (k % 2 == 0)
    d = e = k / 2;
  else if (l % 2 == 0)
    e = (k + 1) / 2, d = k / 2;
  else
    e = k / 2, d = (k + 1) / 2;
  k %= MOD, d %= MOD, e %= MOD;
  if (s % 2 == 1)
    cout << ppow(k, s);
  else {
    array<array<long long, 2>, 2> base;
    base[0][0] = base[1][1] = e;
    base[0][1] = base[1][0] = d;
    array<array<long long, 2>, 2> res = ppow(base, s);
    cout << res[0][0] << "\n";
  }
}
