Problem: Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema.

<image>

However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.)

There are three types of customers: some of them bring exactly a 50-yuan note; some of them bring a 100-yuan note and Nephren needs to give a 50-yuan note back to him/her; some of them bring VIP cards so that they don't need to pay for the ticket.

Now n customers are waiting outside in queue. Nephren wants to know how many possible queues are there that they are able to run smoothly (i.e. every customer can receive his/her change), and that the number of 50-yuan notes they have after selling tickets to all these customers is between l and r, inclusive. Two queues are considered different if there exists a customer whose type is different in two queues. As the number can be large, please output the answer modulo p.

Input

One line containing four integers n (1 ≤ n ≤ 105), p (1 ≤ p ≤ 2·109), l and r (0 ≤ l ≤ r ≤ n). 

Output

One line indicating the answer modulo p.

Examples

Input

4 97 2 3


Output

13


Input

4 100 0 4


Output

35

Note

We use A, B and C to indicate customers with 50-yuan notes, customers with 100-yuan notes and customers with VIP cards respectively.

For the first sample, the different possible queues that there are 2 50-yuan notes left are AAAB, AABA, ABAA, AACC, ACAC, ACCA, CAAC, CACA and CCAA, and the different possible queues that there are 3 50-yuan notes left are AAAC, AACA, ACAA and CAAA. So there are 13 different queues satisfying the first sample. Similarly, there are 35 different queues satisfying the second sample.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
long long expo(long long base, long long exponent, long long mod) {
  long long ans = 1;
  while (exponent != 0) {
    if (exponent & 1) ans = (1LL * ans * base) % mod;
    base = (1LL * base * base) % mod;
    exponent >>= 1;
  }
  return ans % mod;
}
long long euclid(long long a, long long b, long long &first,
                 long long &second) {
  if (b) {
    long long d = euclid(b, a % b, second, first);
    return second -= a / b * first, d;
  }
  return first = 1, second = 0, a;
}
long long chinese(long long a, long long m, long long b, long long n) {
  long long first, second;
  euclid(m, n, first, second);
  long long ret = a * (second + m) % m * n + b * (first + n) % n * m;
  if (ret >= m * n) ret -= m * n;
  return ret;
}
vector<pair<long long, long long> > fac;
long long f[20][200005];
long long powers[20][200005];
long long inv[20][200005];
long long mod[20];
long long modpows[20][50];
long long C(long long n, long long r) {
  if (n < 0 or r < 0 or n < r) return 0;
  long long ans = 0, currem = 1;
  for (long long i = 0; i < (long long)fac.size(); i++) {
    long long s = powers[i][n] - powers[i][r] - powers[i][n - r];
    long long rem = f[i][n] * inv[i][r] % mod[i];
    rem = rem * inv[i][n - r] % mod[i];
    if (s >= fac[i].second)
      rem = 0;
    else
      rem = rem * modpows[i][s] % mod[i];
    ans = chinese(ans, currem, rem, mod[i]);
    currem *= mod[i];
  }
  return ans;
}
long long n, p, l, r;
void pre() {
  for (long long i = 2; i * i <= p; i++) {
    if (p % i == 0) {
      long long cnt = 0;
      while (p % i == 0) {
        cnt++;
        p /= i;
      }
      fac.push_back({i, cnt});
    }
  }
  if (p > 1) fac.push_back({p, 1});
  for (long long i = 0; i < (long long)fac.size(); i++) {
    modpows[i][0] = 1;
    for (long long j = 1; j < fac[i].second + 1; j++)
      modpows[i][j] = modpows[i][j - 1] * fac[i].first;
  }
  for (long long i = 0; i < (long long)fac.size(); i++) {
    mod[i] = modpows[i][fac[i].second];
    f[i][0] = 1;
    for (long long j = 1; j < 2 * n + 1; j++) {
      long long d = j;
      powers[i][j] = powers[i][j - 1];
      while (d % fac[i].first == 0) d /= fac[i].first, powers[i][j]++;
      f[i][j] = f[i][j - 1] * d % mod[i];
    }
    inv[i][2 * n] = expo(
        f[i][2 * n], (mod[i] / fac[i].first) * (fac[i].first - 1) - 1, mod[i]);
    for (long long j = 2 * n - 1; j >= 0; j--) {
      long long d = (j + 1);
      while (d % fac[i].first == 0) d /= fac[i].first;
      inv[i][j] = inv[i][j + 1] * d % mod[i];
    }
  }
}
void solve() {
  cin >> n >> p >> l >> r;
  long long P = p, ans = 0;
  pre();
  for (long long i = 0; i < n + 1; i++) {
    long long m = n - i, ll = l, rr = r;
    if ((m - r) % 2) r--;
    if ((m - l) % 2) l++;
    ans = (ans + C(n, i) * (C(m, (m - l) / 2) - C(m, (m - r) / 2 - 1) + P)) % P;
    l = ll;
    r = rr;
  }
  cout << ans << '\n';
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}