#include <bits/stdc++.h>
using namespace std;
const long long mk = 100005;
const long long mod = 998244353;
long long n, m, l, r;
vector<long long> g[mk];
long long binpow(long long a, long long p) {
  if (p == 0) return 1;
  if (p == 1) return a;
  long long t = binpow(a, p / 2);
  if (p & 1)
    return ((t * t) % mod * a) % mod;
  else
    return (t * t) % mod;
}
long long init() {
  cin >> n >> m >> l >> r;
  if (n * m % 2 == 1) {
    return binpow(r - l + 1, n * m);
  } else {
    long long even = r / 2 - (l - 1) / 2;
    long long odd = (r - r / 2) - ((l - 1) - (l - 1) / 2);
    long long c = binpow(even + odd, n * m);
    long long d = binpow(even - odd, n * m);
    return ((c + d + mod * ((c + d) % 2 == 1)) / 2) % mod;
  }
}
signed main() { cout << init(); }
