#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long int modInverse(long long int n, long long int p) {
  return power(n, p - 2, p);
}
struct point {
  long long int x, y;
};
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n, m, L, R;
  cin >> n >> m >> L >> R;
  long long int o, e;
  if (L % 2 == 0 && R % 2 == 0) {
    o = (R - L) / 2;
    e = R - L + 1 - o;
  } else if (L % 2 != 0 && R % 2 != 0) {
    e = (R - L) / 2;
    o = R - L + 1 - e;
  } else {
    o = (R - L + 1) / 2;
    e = o;
  }
  long long int x = o, y = e;
  long long int sum1 = x * (modInverse(y, 998244353));
  sum1 %= 998244353;
  sum1 += 1;
  sum1 = power(sum1, n * m, 998244353);
  long long int sum2 = x * (modInverse(y, 998244353));
  sum2 = -sum2;
  if (sum2 < 0) {
    sum2 += 998244353;
  }
  sum2 %= 998244353;
  sum2 += 1;
  sum2 %= 998244353;
  sum2 = power(sum2, n * m, 998244353);
  sum2 = -sum2;
  if (sum2 < 0) {
    sum2 += 998244353;
  }
  long long int fsum = sum1 + sum2;
  fsum %= 998244353;
  fsum *= modInverse(2, 998244353);
  fsum %= 998244353;
  fsum *= power(y, n * m, 998244353);
  fsum %= 998244353;
  long long int total = power(R - L + 1, n * m, 998244353);
  if ((n * m) % 2 != 0) {
    cout << total << "\n";
  } else {
    long long int ans = total - fsum;
    if (ans < 0) {
      ans += 998244353;
    }
    cout << ans << "\n";
  }
}
