#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct Mint {
  static const ll mod = 998244353;
  ll val;
  Mint() { val = 0; }
  Mint(ll a) {
    val = a;
    verify_value();
  }
  void verify_value() {
    if (val >= mod) val %= mod;
    if (val < 0) val %= mod, val += mod;
  }
  Mint pow(ll p) const {
    Mint cur = Mint(val), ret = 1;
    while (p > 0) {
      if (p & 1) ret *= cur;
      cur *= cur;
      p >>= 1LL;
    }
    return ret;
  }
  Mint inv() const {
    if (val == 0) cerr << "WARNING: inv() is called with 0." << endl;
    return pow(mod - 2);
  }
  Mint operator+() const { return *this; }
  Mint operator-() const { return Mint(mod - val); }
  Mint operator+=(const Mint &a) {
    val += a.val;
    if (val >= mod) val -= mod;
    return Mint(val);
  }
  Mint operator*=(const Mint &a) {
    val *= a.val;
    if (val >= mod) val %= mod;
    return Mint(val);
  }
  Mint operator-=(const Mint &a) { return *this += -a; }
  Mint operator/=(const Mint &a) { return *this *= a.inv(); }
  Mint operator++() { return *this += Mint(1); }
  Mint operator--() { return *this -= Mint(1); }
  Mint operator++(int) {
    Mint ret = *this;
    ++(*this);
    return ret;
  }
  Mint operator--(int) {
    Mint ret = *this;
    --(*this);
    return ret;
  }
  operator ll() const { return val; }
};
Mint operator+(const Mint &a, const Mint &b) {
  ll ret = a.val + b.val;
  if (ret >= Mint::mod) ret -= Mint::mod;
  return Mint(ret);
}
Mint operator*(const Mint &a, const Mint &b) {
  ll ret = a.val * b.val;
  if (ret >= Mint::mod) ret %= Mint::mod;
  return Mint(ret);
}
Mint operator-(const Mint &a, const Mint &b) { return a + (-b); }
Mint operator/(const Mint &a, const Mint &b) { return a * b.inv(); }
ostream &operator<<(ostream &out, const Mint &a) { return out << a.val; }
istream &operator>>(istream &in, Mint &a) {
  in >> a.val;
  a.verify_value();
  return in;
}
Mint pow(Mint a, ll b) { return a.pow(b); }
int main() {
  ll n, m, l, r;
  cin >> n >> m >> l >> r;
  Mint odd = (r - l + 1) / 2;
  if ((r - l + 1) % 2 == 1 && l % 2 == 1) odd++;
  Mint even = Mint(r - l + 1) - odd;
  cerr << odd << " " << even << endl;
  if (n * m & 1) {
    cout << pow(even + odd, n * m) << endl;
  } else {
    cout << (pow(even + odd, n * m) + pow(even - odd, n * m)) / Mint(2) << endl;
  }
  return 0;
}
