#include <bits/stdc++.h>
using namespace std;
vector<long long> mul(vector<long long> a, vector<long long> b) {
  vector<long long> c(4);
  c[0] = a[0] * b[0] + a[1] * b[2];
  c[0] %= 998244353;
  c[1] = a[0] * b[1] + a[1] * b[3];
  c[1] %= 998244353;
  c[2] = a[2] * b[0] + a[3] * b[2];
  c[2] %= 998244353;
  c[3] = a[2] * b[1] + a[3] * b[3];
  c[3] %= 998244353;
  return c;
}
vector<long long> pot(vector<long long> x, long long p) {
  if (p == 0) return {1, 0, 0, 1};
  vector<long long> u = pot(x, p / 2);
  u = mul(u, u);
  if (p % 2 == 1) u = mul(u, x);
  return u;
}
int main() {
  long long n, m, l, r;
  cin >> n >> m >> l >> r;
  long long c0, c1;
  if (l % 2 == 0) {
    c0 = (r - l) / 2 + 1;
    c1 = (r - l + 1) / 2;
  } else {
    c0 = (r - l + 1) / 2;
    c1 = (r - l) / 2 + 1;
  }
  vector<long long> v = {c0, c1, c1, c0};
  vector<long long> u = pot(v, n * m);
  long long z;
  if (n * m % 2 == 0) {
    z = u[0];
  } else {
    z = u[0] + u[2];
  }
  z %= 998244353;
  cout << z << "\n";
}
