#include <bits/stdc++.h>
using namespace std;
long long n, m, r, l, E, O;
long long Pow(long long a, long long p) {
  if (a == 0) return 0;
  long long res = 1;
  while (p) {
    if (p & 1) res = res * a % 998244353;
    a = a * a % 998244353;
    p >>= 1;
  }
  return res;
}
signed main() {
  cin >> n >> m >> l >> r;
  if (n * m & 1)
    cout << Pow((r - l + 1) % 998244353, n * m % (998244353 - 1));
  else {
    long long E = (r >> 1) - (l - 1 >> 1);
    long long O = r - l + 1 - E;
    cout << ((Pow((O + E) % 998244353, n * m % (998244353 - 1)) +
              Pow((O - E + 998244353) % 998244353, n * m % (998244353 - 1))) *
             499122177 % 998244353)
         << endl;
  }
  return 0;
}
