#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
void tracer(istream_iterator<string> it) {}
template <typename T, typename... Args>
void tracer(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << " | ";
  tracer(++it, args...);
}
const long long MOD = 998244353;
const long double err = 1e-10;
const int N = 2e5 + 5;
long long binpow(long long aa, long long xx) {
  long long anss = 1;
  while (xx > 0) {
    if (xx & 1) {
      anss = (1ll * anss * aa) % MOD;
    }
    xx /= 2;
    aa = (1ll * aa * aa) % MOD;
  }
  return anss;
}
void solve() {
  long long n, m, l, r;
  cin >> n >> m >> l >> r;
  long long total = (r - l + 1);
  long long evens = total / 2 + (total % 2 != 0 && l % 2 == 0),
            odds = total - evens;
  if (n % 2 == 0 || m % 2 == 0) {
    cout << ((((binpow(total, n * m) + binpow(evens - odds, n * m)) % MOD) *
              binpow(2, MOD - 2)) %
                 MOD +
             MOD) %
                MOD
         << "\n";
  } else {
    cout << binpow(total, n * m) << "\n";
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int T = 1;
  for (int i = 1; i <= T; i++) {
    solve();
  }
  return 0;
}
