#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
template <typename T>
T sqr(T a) {
  return a * a;
}
template <typename T>
int sign(T a) {
  if (a == 0) return 0;
  return (a > 0 ? 1 : -1);
}
template <typename T1, typename T2>
T2 sum_mod(T1 x, T2 MOD) {
  if (x < 0) x += MOD;
  if (x >= MOD) x -= MOD;
  return x;
}
template <typename T1, typename T2>
T2 mul_mod(T1 x, T2 MOD) {
  if (x < 0) return (abs(x) % MOD == 0 ? 0 : MOD - abs(x) % MOD);
  return x % MOD;
}
template <typename T>
bool uax(T& a, const T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool uin(T& a, const T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& p) {
  in >> p.first >> p.second;
  return in;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2>& p) {
  out << p.first << ' ' << p.second;
  return out;
}
const int LOG = 18;
const int N = (int)1e5 + 7;
const int MAXN = (int)2e3 + 7;
const int MOD = (int)998244353;
const int INF = (int)1e9 + 7;
const int CONST = 300;
const long long LINF = (int64_t)2e15;
const long double PI = 3.1415926535897932384626433832795;
const long double EPS = 1;
long long n, m, l, r;
int bin_pow(int a, long long p) {
  int res = 1;
  while (p) {
    if (p & 1) res = 1LL * res * a % MOD;
    a = 1LL * a * a % MOD;
    p >>= 1;
  }
  return res;
}
int mul(int a, int b) { return 1LL * a * b % MOD; }
int divs(int a, int b) { return mul(a, bin_pow(b, MOD - 2)); }
int main() {
  double start = clock();
  cout << fixed << setprecision(20);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> l >> r;
  int cnt = bin_pow(r - l + 1, n * m);
  if (n * m % 2 == 1) {
    cout << cnt;
    return 0;
  }
  if ((r - l + 1) % 2 == 0)
    cout << divs(cnt, 2);
  else
    cout << divs((cnt + 1) % MOD, 2);
}
