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;
const int MN = 100010;
vector<int> pr, pchk;
void Sieve() {
  pchk = vector<int>(MN, 0);
  for (int i = 2; i < MN; i++) {
    if (!pchk[i]) {
      pr.push_back(i);
    }
    for (int j = 0; j < pr.size() && i * pr[j] < MN; j++) {
      pchk[i * pr[j]] = 1;
      if (i % pr[j] == 0) break;
    }
  }
}
int po(int x, int n, int m) {
  int ret = 1;
  while (n) {
    if (n & 1) ret = 1LL * ret * x % m;
    x = 1LL * x * x % m;
    n >>= 1;
  }
  return ret;
}
int inv(int x, int p, int m) { return po(x, m - m / p - 1, m); }
int N, P, L, R;
vector<pair<int, int> > fact;
unordered_map<int, vector<int> > prec;
void Fact() {
  int n = P;
  for (int i = 0; i < pr.size() && pr[i] <= n; i++) {
    if (n % pr[i] == 0) {
      int cnt = 0;
      while (n % pr[i] == 0) {
        cnt++;
        n /= pr[i];
      }
      fact.push_back(pair<int, int>(pr[i], cnt));
    }
  }
  if (n != 1) fact.push_back(pair<int, int>(n, 1));
}
void Prec() {
  for (int i = 0; i < fact.size(); i++) {
    int p = fact[i].first;
    int t = fact[i].second;
    int m = po(p, t, 2e9 + 1);
    prec[p].resize(MN);
    prec[p][0] = 1;
    for (int j = 1; j < MN; j++) {
      prec[p][j] = 1LL * prec[p][j - 1] * (j % p == 0 ? 1 : j) % m;
    }
  }
}
int calc3(int n, int p, int m) {
  if (n == 0) return 0;
  int ret = 0;
  ret += n / p;
  ret += calc3(n / p, p, m);
  return ret;
}
long long calc2(int n, int p, int m) {
  if (n == 0) return 1;
  return 1LL * prec[p][n] * calc2(n / p, p, m) % m;
}
long long calc1(int n, int k, int p, int m) {
  long long x = calc3(n, p, m) - calc3(n - k, p, m) - calc3(k, p, m);
  long long y = 1LL * calc2(n, p, m) * inv(calc2(n - k, p, m), p, m) % m *
                inv(calc2(k, p, m), p, m) % m;
  return 1LL * y * po(p, x, m) % m;
}
long long comb(int n, int k) {
  long long R = 0, M = 1;
  for (int i = 0; i < fact.size(); i++) {
    int p = fact[i].first;
    int t = fact[i].second;
    int m = po(p, t, 2e9 + 1);
    long long r = calc1(n, k, p, m);
    long long a = 1LL * (r + m - R % m) * inv(M, p, m) % m;
    R += 1LL * a * M % (m * M);
    R %= (m * M);
    M *= m;
  }
  return R;
}
int main() {
  cin >> N >> P >> L >> R;
  Sieve();
  Fact();
  Prec();
  long long ans = 0;
  for (int c = 0; c <= N; c++) {
    long long tmp = 0;
    if ((N - c) % 2 == 0) {
      if (N - c >= (L % 2 == 0 ? L : L + 1))
        tmp += comb(N - c, (N - c) / 2 - (L % 2 == 0 ? L : L + 1) / 2);
      if (N - c >= (R % 2 == 0 ? R + 2 : R + 1))
        tmp -= comb(N - c, (N - c) / 2 - (R % 2 == 0 ? R + 2 : R + 1) / 2);
      tmp = (tmp % P + P) % P;
    }
    if ((N - c) % 2 == 1) {
      if (N - c >= (L % 2 == 1 ? L : L + 1))
        tmp += comb(N - c, (N - c) / 2 - (L % 2 == 1 ? L : L + 1) / 2);
      if (N - c >= (R % 2 == 1 ? R + 2 : R + 1))
        tmp -= comb(N - c, (N - c) / 2 - (R % 2 == 1 ? R + 2 : R + 1) / 2);
    }
    ans += 1LL * comb(N, c) * tmp % P;
    ans %= P;
  }
  cout << ans;
}