#include <bits/stdc++.h>
using namespace std;
const long long int mod = 998244353;
long long int powll(long long int b, long long int p) {
  if (p == 0) return 1;
  if (p == 1) return b % mod;
  long long int ret = powll(b, p >> 1);
  ret = (ret * ret) % mod;
  if (p & 1) ret = (ret * (b % mod)) % mod;
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n, m, l, r;
  cin >> n >> m >> l >> r;
  if ((n * m) & 1)
    cout << powll(r - l + 1, n * m) << endl;
  else
    cout << (((powll(r - l + 1, n * m) + ((r - l + 1) & 1)) % mod) *
             powll(2, mod - 2)) %
                mod
         << endl;
  return 0;
}
