#include <bits/stdc++.h>
#pragma optimize("O3")
using namespace std;
const long long MOD = 998244353;
const long long INF = 1e18 + 7;
const int base = 2e5 + 1;
const long long MAX = 3 * 1e5 + 1;
const double EPS = 1e-9;
const double PI = acos(-1.);
const int MAXN = 1e5 + 47;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long mult(long long a, long long b) { return (a * b) % MOD; }
long long binpow(long long a, long long n) {
  if (n == 0) return 1;
  if (n % 2 == 1) return mult(a, binpow(a, n - 1));
  long long b = binpow(a, n / 2);
  return mult(b, b);
}
int main() {
  long long n, m, l, r;
  cin >> n >> m >> l >> r;
  long long t = binpow(r - l + 1, n * m);
  if (n * m % 2)
    cout << t;
  else {
    if ((r - l + 1) % 2 == 0)
      cout << ((t * (MOD + 1)) / 2) % MOD;
    else
      cout << ((t + 1) * (MOD + 1) / 2) % MOD;
  }
  return 0;
}
