#include <bits/stdc++.h>
using namespace std;
long long n, m, l, r, t1, t2, t3, ans;
const long long mod = 998244353;
long long fpow(long long b, long long p) {
  if (b == 0) return 0;
  long long ans = 1, t = b;
  while (p) {
    if (p % 2) ans = (ans * t) % mod;
    t = (t * t) % mod;
    p /= 2;
  }
  return ans;
}
int main() {
  scanf("%lld%lld%lld%lld", &n, &m, &l, &r);
  if (n % 2 && m % 2) {
    t1 = (r - l + 1) % mod;
    t3 = (n % (mod - 1)) * (m % (mod - 1)) % (mod - 1);
    ans = fpow(t1, t3);
  } else {
    long long o = (r + 1) / 2 - l / 2, e = r / 2 - (l - 1) / 2;
    t1 = (e + o) % mod;
    t2 = ((e - o) % mod + mod) % mod;
    t3 = (n % (mod - 1)) * (m % (mod - 1)) % (mod - 1);
    ans = fpow(t1, t3) + fpow(t2, t3);
    ans = (ans % mod + mod) % mod;
    ans = ans * fpow(2, mod - 2) % mod;
  }
  printf("%lld", ans);
}
