#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
long long quick(long long a, long long n) {
  long long ans = 1;
  while (n > 0) {
    if (n & 1) {
      ans = ans * a % mod;
    }
    n >>= 1;
    a = a * a % mod;
  }
  return ans;
}
void solve() {
  long long n, m, L, R;
  scanf("%lld%lld%lld%lld", &n, &m, &L, &R);
  if (n * m % 2 != 0)
    printf("%lld\n", quick(R - L + 1, n * m));
  else if (R - L + 1 & 1)
    printf("%lld\n",
           ((quick(R - L + 1, n * m) + 1) * quick(2ll, mod - 2)) % mod);
  else
    printf("%lld\n", ((quick(R - L + 1, n * m)) * quick(2ll, mod - 2)) % mod);
}
int main(void) {
  solve();
  return 0;
}
