#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
const int N = 5e5 + 5, M = 3, mod = 998244353;
struct matrix {
  int n;
  long long a[M][M];
  matrix(int _n, long long val) {
    memset(a, 0, sizeof a);
    n = _n;
    for (int i = 0; i < n; i++) a[i][i] = val;
  }
};
matrix operator*(const matrix &a, const matrix &b) {
  matrix c(a.n, 0);
  for (int i = 0; i < a.n; i++)
    for (int j = 0; j < a.n; j++)
      for (int k = 0; k < a.n; k++)
        c.a[i][j] = (c.a[i][j] + a.a[i][k] * b.a[k][j] % mod) % mod;
  return c;
}
matrix power(matrix a, long long b) {
  matrix res(a.n, 1), temp = a;
  while (b) {
    if (b & 1LL) res = res * temp;
    temp = temp * temp;
    b >>= 1LL;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long n, m, l, r;
  cin >> n >> m >> l >> r;
  n = n * m;
  long long even = r / 2 - (l - 1) / 2;
  long long odd = r - l + 1 - even;
  even %= mod, odd %= mod;
  matrix mat(2, even);
  mat.a[0][1] = mat.a[1][0] = odd;
  mat = power(mat, n);
  if (n % 2)
    cout << (mat.a[0][1] + mat.a[0][0]) % mod;
  else
    cout << mat.a[0][0];
  return 0;
}
