#include <bits/stdc++.h>
using namespace std;
const int M = 998244353;
int n, m, l, r, Mx[2][2], dp[2] = {1, 0}, p[2][2];
int pw(int x, int y) {
  int rs = 1;
  for (; y; y >>= 1, x = 1ll * x * x % M)
    if (y & 1) rs = 1ll * rs * x % M;
  return rs;
}
int main() {
  scanf("%d %d %d %d", &n, &m, &l, &r);
  if ((n * m) & 1) {
    int ans = pw(r - l + 1, n);
    ans = pw(ans, m);
    printf("%d\n", ans);
  } else {
    long long t = 1ll * n * m;
    Mx[1][0] = Mx[0][1] = (r - l + 1) / 2;
    Mx[0][0] = Mx[1][1] = r - l + 1 - Mx[1][0];
    for (; t; t >>= 1) {
      if (t & 1) {
        int x = dp[0], y = dp[1];
        dp[0] = (1ll * x * Mx[0][0] + 1ll * y * Mx[0][1]) % M;
        dp[1] = (1ll * x * Mx[1][0] + 1ll * y * Mx[1][1]) % M;
      }
      for (int i = 0; i < 2; ++i) {
        for (int o = 0; o < 2; ++o) {
          p[i][o] = 0;
          for (int u = 0; u < 2; ++u) {
            p[i][o] = (p[i][o] + 1ll * Mx[i][u] * Mx[u][o]) % M;
          }
        }
      }
      for (int i = 0; i < 2; ++i) {
        for (int o = 0; o < 2; ++o) {
          Mx[i][o] = p[i][o];
        }
      }
    }
    printf("%d\n", dp[0]);
  }
}
