#include <bits/stdc++.h>
using namespace std;
template <class T>
using v2d = vector<vector<T> >;
template <class T>
bool uin(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
const int maxN = 1e5 + 10;
const long long mod = 998244353;
long long n, m, L, R;
long long power(long long a, long long b) {
  long long r = 1;
  while (b) {
    if (b & 1) {
      r = r * a % mod;
    }
    b /= 2;
    a = a * a % mod;
  }
  return r;
}
void solve() {
  cin >> n >> m >> L >> R;
  long long d = n * m, ans = 0;
  ans = power(R - L + 1, d);
  if (d % 2 == 0) {
    if (L % 2 == R % 2) {
      ans = (ans + 1) % mod;
    }
    ans = ans * power(2, mod - 2) % mod;
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
