#include <bits/stdc++.h>
using namespace std;
long long fastpow(long long a, long long b) {
  if (b == 0) return 1;
  long long x = fastpow(a, b / 2);
  x *= x;
  x %= 998244353;
  if (b % 2 == 0)
    return x;
  else
    return (x * a) % 998244353;
}
int main() {
  long long n, m, l, r, od, ev, res = 0;
  scanf("%lld %lld %lld %lld", &n, &m, &l, &r);
  long long tot = r - l + 1, cell = n * m;
  if (cell % 2 == 1) {
    res = fastpow(tot, cell);
  } else {
    if (tot % 2 == 0)
      res = fastpow(tot, cell);
    else
      res = fastpow(tot, cell) + 1;
    res *= fastpow(2LL, 998244353 - 2);
    res %= 998244353;
  }
  printf("%lld\n", res);
  return 0;
}
