#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + c - '0', c = getchar();
  }
  return x * f;
}
const int MOD = 998244353;
inline int inc(int x, int y) {
  x += y;
  return x >= MOD ? x - MOD : x;
}
inline int mul(int x, int y) { return 1LL * x * y % MOD; }
inline void add(int &x, int y) {
  y += x;
  x = y >= MOD ? y - MOD : y;
}
struct matrix {
  int mat[2][2];
  matrix() { memset(mat, 0, sizeof mat); }
  inline friend matrix operator*(const matrix &a, const matrix &b) {
    matrix res;
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++)
        for (int k = 0; k < 2; k++)
          add(res.mat[i][j], mul(a.mat[i][k], b.mat[k][j]));
    return res;
  }
};
inline matrix qpow(matrix x, long long y) {
  matrix res;
  res.mat[0][0] = res.mat[1][1] = 1;
  for (; y; y >>= 1, x = x * x)
    if (y & 1LL) res = res * x;
  return res;
}
inline int qpow(int x, long long y) {
  int res = 1;
  for (; y; y >>= 1, x = 1LL * x * x % MOD)
    if (y & 1LL) res = 1LL * res * x % MOD;
  return res;
}
int main() {
  int n, m, L, R;
  cin >> n >> m >> L >> R;
  if (((1LL * n * m) & 1LL)) {
    printf("%d\n", qpow((R - L + 1) % MOD, 1LL * n * m));
    return 0;
  }
  int x = R / 2 - (L - 1) / 2;
  int y = R - L + 1 - x;
  x %= MOD, y %= MOD;
  matrix A, B;
  A.mat[0][0] = 1, A.mat[0][1] = 0;
  B.mat[0][0] = B.mat[1][1] = y;
  B.mat[0][1] = B.mat[1][0] = x;
  A = A * qpow(B, 1LL * n * m);
  printf("%d\n", A.mat[0][0]);
  return 0;
}
