#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f, mod = 998244353;
const double pi = 3.1415926535897932, eps = 1e-6;
void chmax(int &x, int y) {
  if (x < y) x = y;
}
void chmin(int &x, int y) {
  if (x > y) x = y;
}
long long n, m, L, R;
long long qpow(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y & 1) res = res * x % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return res;
}
long long inv(long long x) { return qpow(x, mod - 2); }
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m >> L >> R;
  if (n * m % 2) {
    cout << qpow(R - L + 1, n * m) << endl;
    return 0;
  }
  long long wa = R / 2 - (L - 1) / 2;
  long long wb = (R + 1) / 2 - L / 2;
  if (wa == wb) {
    long long val = qpow(R - L + 1, n * m);
    cout << val * inv(2) % mod << endl;
  }
  if (wa == wb - 1) {
    long long val = qpow(R - L + 1, n * m);
    cout << ((val - 1) * inv(2) % mod + 1ll + mod) % mod << endl;
  }
  if (wa == wb + 1) {
    long long val = qpow(R - L + 1, n * m);
    cout << ((val - 1) * inv(2) % mod + 1ll + mod) % mod << endl;
  }
  return 0;
}
