#include <bits/stdc++.h>
using namespace std;
const long long p = 998244353;
long long pow_mod(long long, long long);
int main() {
  long long n, m, l, r, num, are, ans;
  scanf("%lld%lld%lld%lld", &n, &m, &l, &r);
  num = r - l + 1;
  are = n * m;
  if (are % 2) {
    printf("%lld", pow_mod(num, are));
  } else {
    if (num % 2 == 0)
      printf("%lld", pow_mod(num, are - 1) * num / 2 % p);
    else
      printf("%lld", (pow_mod(num, are) + 1) * (p + 1) / 2 % p);
  }
  return 0;
}
long long pow_mod(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y & 1) {
      res *= x;
      res %= p;
    }
    x *= x;
    x %= p;
    y >>= 1;
  }
  return res;
}
