#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
long long mod = 998244353;
long long zero = 0;
long long one = 1;
long long pow(long long a, long long b, long long md = mod) {
  long long ans = 1;
  while (b > 0) {
    if (b & 1) ans = (ans * a) % md;
    a = (a * a) % mod;
    b = b >> 1;
  }
  return ans;
}
long long inv(long long a) { return pow(a, mod - 2); }
void solve() {
  long long n, m, l, r;
  cin >> n >> m >> l >> r;
  long long dif = r - l + 1;
  long long pr = n * m;
  long long nm = pr;
  if (pr & 1) {
    cout << pow(dif, nm) << '\n';
    return;
  }
  long long even = dif / 2;
  long long odd = dif - even;
  if (even < odd) swap(even, odd);
  cout << (((((pow(dif, nm) + pow(even - odd, nm)) % mod) * inv(2)) % mod +
            mod) %
           mod)
       << '\n';
}
signed main() {
  auto start = high_resolution_clock::now();
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << fixed << setprecision(15);
  long long t = 1;
  while (t--) solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start);
  cerr << "duration.count()"
       << " is " << duration.count() << '\n';
  ;
  return 0;
}
