#include <bits/stdc++.h>
using namespace std;
long long p = 998244353, n, m, l, r, cnt0, cnt1;
long long _bp(long long val, long long st) {
  if (st == 0) {
    return 1;
  }
  long long temp = _bp(val, st / 2);
  temp *= temp;
  temp %= p;
  if (st % 2 == 1) {
    temp *= val;
    temp %= p;
  }
  return temp;
}
int main() {
  cin >> n >> m >> l >> r;
  if (l == r) {
    cout << 1;
    return 0;
  }
  long long ans = _bp(r - l + 1, n * m);
  if ((n * m) % 2 == 1) {
    cout << ans << '\n';
    return 0;
  }
  if ((r - l + 1) % 2 == 0) {
    cout << (ans * _bp(2, p - 2)) % p;
  } else {
    cout << ((ans + 1) * _bp(2, p - 2)) % p;
  }
}
