#include <bits/stdc++.h>
using namespace std;
const long long oo = 1e18;
const long long MOD = 998244353;
long long qpow(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = res * a % MOD;
    a = a * a % MOD;
    b /= 2;
  }
  return res;
}
long long inv(long long x) { return qpow(x, MOD - 2); }
vector<vector<long long>> identity(long long n) {
  vector<vector<long long>> A(n, vector<long long>(n));
  for (long long i = 0; i < n; i++) A[i][i] = 1;
  return A;
}
vector<vector<long long>> mul(const vector<vector<long long>> &A,
                              const vector<vector<long long>> &B) {
  vector<vector<long long>> C(A.size(), vector<long long>(B[0].size()));
  for (long long i = 0; i < C.size(); i++)
    for (long long j = 0; j < C[i].size(); j++)
      for (long long k = 0; k < A[i].size(); k++)
        C[i][j] = (C[i][j] + A[i][k] * B[k][j] % MOD) % MOD;
  return C;
}
vector<vector<long long>> qpow(vector<vector<long long>> A, long long e) {
  vector<vector<long long>> res = identity(A.size());
  while (e) {
    if (e & 1) res = mul(res, A);
    A = mul(A, A);
    e /= 2;
  }
  return res;
}
void print(vector<vector<long long>> A) {
  cerr << '\n';
  for (long long i = 0; i < A.size(); i++) {
    cerr << "[";
    for (long long j = 0; j < A[i].size(); j++) {
      if (j) cerr << ", ";
      cerr << A[i][j];
    }
    cerr << "]" << '\n';
  }
  cerr << '\n';
}
long long N, M, L, R;
long long fact[1000000];
long long comb(long long n, long long k) {
  return fact[n] * inv(fact[n - k] * fact[k] % MOD) % MOD;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> N >> M >> L >> R;
  long long I = -1, P = -1;
  if (L & 1) {
    if ((R - L + 1) % 2 == 0) {
      I = (R - L + 1) / 2;
      P = (R - L + 1) / 2;
    } else {
      I = (R - L + 1) / 2 + 1;
      P = (R - L + 1) / 2;
    }
  } else {
    if ((R - L + 1) % 2 == 0) {
      P = (R - L + 1) / 2;
      I = (R - L + 1) / 2;
    } else {
      P = (R - L + 1) / 2 + 1;
      I = (R - L + 1) / 2;
    }
  }
  vector<vector<long long>> mt = {{P, I}, {I, P}};
  mt = qpow(mt, N * M - 1);
  long long sol = (mt[0][0] * P % MOD + mt[0][1] * I % MOD) % MOD;
  long long sol2 = (mt[1][0] * P % MOD + mt[1][1] * I % MOD) % MOD;
  if (N * M & 1)
    cout << (sol2 + sol) % MOD << '\n';
  else
    cout << sol << '\n';
  return 0;
}
