#include <bits/stdc++.h>
using namespace std;
const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng(
    (unsigned int)chrono::steady_clock::now().time_since_epoch().count());
long long mod = 998244353;
long long pow2(long long a, long long b) {
  long long ans = 1;
  while (b > 0) {
    if (b & 1) ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}
class M2 {
 public:
  long long x00, x01, x10, x11;
  void multi(M2 p) {
    long long _x00 = x00 * p.x00 + x01 * p.x10;
    long long _x01 = x00 * p.x01 + x01 * p.x11;
    long long _x10 = x10 * p.x00 + x11 * p.x10;
    long long _x11 = x10 * p.x01 + x11 * p.x11;
    x00 = _x00 % mod;
    x01 = _x01 % mod;
    x10 = _x10 % mod;
    x11 = _x11 % mod;
  }
};
M2 pow2m(M2 mat, long long b) {
  M2 ans;
  ans.x00 = ans.x11 = 1;
  ans.x10 = ans.x01 = 0;
  while (b > 0) {
    if (b & 1) ans.multi(mat);
    mat.multi(mat);
    b >>= 1;
  }
  return ans;
}
long long n, m, L, R;
int main() {
  cin >> n >> m >> L >> R;
  if (n * m % 2 == 1) {
    cout << pow2(R - L + 1, n * m) << endl;
  } else {
    long long a = (R - L + 1) / 2, b = (R - L + 1) / 2;
    if ((R - L + 1) % 2 == 1) {
      if (L % 2 == 0)
        a += 1;
      else
        b += 1;
    }
    M2 mat;
    mat.x00 = mat.x11 = a;
    mat.x10 = mat.x01 = b;
    M2 r = pow2m(mat, n * m);
    cout << r.x00 << endl;
  }
  return 0;
}
