#include <bits/stdc++.h>
using namespace std;
int n, m, K;
inline void Rd(int &res) {
  res = 0;
  register char c;
  while (c = getchar(), c < 48)
    ;
  do res = (res << 3) + (res << 1) + (c ^ 48);
  while (c = getchar(), c > 47);
}
int L, R;
struct Matrix {
  int a[135][135];
  int sz;
  Matrix() { clear(); }
  inline void clear() { memset(a, 0, sizeof(a)); }
  void init(int s) {
    sz = s;
    clear();
    for (int i = 0; i < sz; i++) a[i][i] = 1;
  }
  inline int *operator[](int id) { return a[id]; }
  inline Matrix operator*(const Matrix &b) {
    Matrix c;
    c.sz = sz;
    for (int i = 0; i < sz; i++)
      for (int j = 0; j < sz; j++)
        for (int k = 0; k < sz; k++) {
          c[i][k] += 1ll * a[i][j] * b.a[j][k] % 998244353;
          c[i][k] >= 998244353 && (c[i][k] -= 998244353);
        }
    return c;
  }
} S, S1;
Matrix Pow(Matrix x, long long k) {
  Matrix res;
  res.init(x.sz);
  while (k) {
    if (k & 1) res = res * x;
    x = x * x;
    k >>= 1;
  }
  return res;
}
int Pow(int x, int k) {
  int res = 1;
  while (k) {
    if (k & 1) res = 1ll * res * x % 998244353;
    x = 1ll * x * x % 998244353;
    k >>= 1;
  }
  return res;
}
int a, b;
int main() {
  scanf("%d%d%d%d", &n, &m, &L, &R);
  if ((n % 2 == 1 && m % 2 == 1)) {
    int res = Pow(R - L + 1, 1ll * n * m % (998244353 - 1));
    printf("%d\n", res);
    return 0;
  }
  if (L & 1)
    a = (R - L + 2) / 2;
  else
    a = (R - L + 1) / 2;
  b = R - L + 1 - a;
  S.init(2);
  S.a[0][0] = b, S.a[0][1] = a, S.a[1][0] = a, S.a[1][1] = b;
  S1.init(2);
  S1.a[0][0] = 1, S1.a[0][1] = 0, S1.a[1][0] = 0, S1.a[1][1] = 0;
  S = Pow(S, 1ll * n * m);
  S1 = S1 * S;
  printf("%d\n", S1.a[0][0]);
  return 0;
}
