#include <bits/stdc++.h>
using namespace std;
const int maxn = 105;
const int mod = 998244353;
long long qp(long long a, long long n) {
  a %= mod;
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
template <class T>
inline bool scan(T& ret) {
  char c;
  int sgn;
  if (c = getchar(), c == EOF) return 0;
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  sgn = (c == '-') ? -1 : 1;
  ret = (c == '-') ? 0 : (c - '0');
  while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
  ret *= sgn;
  return 1;
}
long long n, m, L, R;
long long inv(long long x) { return qp(x, mod - 2); }
int main(int argc, char* argv[]) {
  cin >> n >> m >> L >> R;
  long long tot = R - L + 1;
  long long even = (L % 2 == 0 && R % 2 == 0) ? tot / 2 + 1 : tot / 2;
  long long odd = tot - even;
  if (even == 0) {
    printf("%lld\n", qp(odd, n * m));
    exit(0);
  } else if (odd == 0) {
    printf("%lld\n", qp(even, n * m));
    exit(0);
  }
  long long sz = n * m;
  long long res = (qp(even - odd + mod, sz) + qp(tot, sz)) * inv(2) % mod;
  if (n % 2 && m % 2) {
    swap(even, odd);
    res = (res + (qp(even - odd + mod, sz) + qp(tot, sz)) * inv(2) % mod) % mod;
  }
  cout << res << endl;
  return 0;
}
