#include <bits/stdc++.h>
using namespace std;
const long long fuck = 499122177;
const long long Mod = 998244353;
long long pow_mod(long long a, long long n, long long m) {
  long long ans = 1LL;
  while (n) {
    if (n & 1LL) {
      ans = (ans * a) % m;
    }
    a = (a * a) % m;
    n >>= 1LL;
  }
  return ans;
}
int main() {
  long long n, m, L, R;
  scanf("%lld%lld%lld%lld", &n, &m, &L, &R);
  long long tmp = n * m;
  if (n % 2 == 1 && m % 2 == 1) {
    long long Ans = pow_mod(R - L + 1LL, tmp, Mod);
    cout << Ans << endl;
    return 0;
  }
  long long op = R / 2LL - (L - 1LL) / 2LL;
  long long fg = R - L + 1LL - op;
  if (op <= fg) swap(op, fg);
  long long h1 = op + fg, h2 = op - fg;
  long long Ans1 = pow_mod(h1, tmp, Mod);
  long long Ans2 = pow_mod(h2, tmp, Mod);
  long long Ans = ((Ans1 + Ans2) % Mod + Mod) % Mod;
  Ans = Ans * fuck % Mod;
  cout << Ans << endl;
  return 0;
}
