#include <bits/stdc++.h>
using namespace std;
constexpr int Mod = 998244353;
int pot(int mnoz, long long wykl) {
  if (wykl == 0) {
    return 1;
  } else {
    int pomo = pot(mnoz, (wykl >> 1));
    pomo = ((long long)pomo * pomo) % Mod;
    if ((wykl & 1) == 1) pomo = ((long long)pomo * mnoz) % Mod;
    return pomo;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m, l, r, wyn;
  cin >> n >> m >> l >> r;
  wyn = pot(r - l + 1, (long long)n * m);
  if ((((long long)n * m) & 1) == 1) {
    cout << wyn << "\n";
  } else {
    cout << ((long long)(wyn + (((r - l + 1) & 1) == 1)) * ((Mod + 1) >> 1)) %
                Mod
         << "\n";
  }
  return 0;
}
