#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double eps = (1e-10);
int isGreater(long double x, long double y) {
  if (abs(x - y) < eps) return 0;
  if (x > y) return 1;
  return -1;
}
const unsigned long long MOD = 998244353;
struct Matrix {
  unsigned long long v[200][200];
  int row, col;
  Matrix(int n, int m, long long a = 0) {
    memset(v, 0, sizeof(v));
    row = n, col = m;
    for (int i = 0; i < row && i < col; i++) v[i][i] = a;
  }
  Matrix operator*(const Matrix& x) const {
    Matrix ret(row, x.col);
    for (int i = 0; i < row; i++) {
      for (int k = 0; k < col; k++) {
        if (v[i][k])
          for (int j = 0; j < x.col; j++) {
            ret.v[i][j] += v[i][k] * x.v[k][j], ret.v[i][j] %= MOD;
          }
      }
    }
    return ret;
  }
  unsigned long long* operator[](int i) { return v[i]; }
  Matrix operator^(const long long& n) const {
    Matrix ret(row, col, 1), x = *this;
    long long y = n;
    while (y) {
      if (y & 1) ret = ret * x;
      y = y >> 1, x = x * x;
    }
    return ret;
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m, l, r;
  cin >> n >> m >> l >> r;
  long long s = 1LL * n * m;
  int p = r - l + 1;
  int e = p / 2, o = p - e;
  Matrix base(2, 1);
  base[0][0] = e;
  base[1][0] = o;
  Matrix trans(2, 2);
  trans[0][0] = trans[1][1] = e;
  trans[0][1] = trans[1][0] = o;
  trans = trans ^ (s - 1);
  base = trans * base;
  unsigned long long ans = base[0][0];
  if (s & 1) ans = (ans + base[1][0]) % MOD;
  cout << ans << '\n';
  return 0;
}
