#include <bits/stdc++.h>
using namespace std;
char s[200001];
int a[200001][27];
const int mod = 998244353;
int quickpow(int x, int y) {
  long long res = 1, base = x;
  while (y) {
    if (y & 1) res *= base, res %= mod;
    y >>= 1;
    base *= base, base %= mod;
  }
  return res;
}
int inv(int x) { return quickpow(x, mod - 2); }
signed main() {
  int n, m, l, r;
  cin >> n >> m >> l >> r;
  int sum1 = r / 2 - (l - 1) / 2;
  int sum2 = r - l + 1 - sum1;
  if (1ll * n * m % 2 == 0)
    cout << 1ll *
                (quickpow(quickpow(sum1 + sum2, n), m) +
                 quickpow(quickpow(sum1 - sum2, n), m)) %
                mod * inv(2) % mod;
  else
    cout << quickpow(quickpow(sum1 + sum2, n), m);
  return 0;
}
