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;
template <class T, class U>
void Min(T &a, U b) {
  if (a > b) a = b;
}
template <class T, class U>
void Max(T &a, U b) {
  if (a < b) a = b;
}
long long pow(long long a, int b, int c) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % c;
    a = 1LL * a * a % c;
    b >>= 1;
  }
  return ans;
}
int f[21][100010], c[21][100010];
vector<pair<int, int> > v;
vector<int> mo;
int cal(int n, int m, int i) {
  int w = c[i][n] - c[i][m] - c[i][n - m], q = mo[i];
  if (w >= v[i].second) return 0;
  long long ans = 1LL * f[i][m] * f[i][n - m] % q;
  ans = pow(ans, q - q / v[i].first - 1, q) * f[i][n] % q;
  return ans * pow(v[i].first, w, q) % q;
}
long long ex_gcd(long long a, long long b, long long &first,
                 long long &second) {
  if (b == 0) {
    first = 1, second = 0;
    return a;
  }
  long long x1, y1, d = ex_gcd(b, a % b, x1, y1);
  first = y1;
  second = x1 - a / b * first;
  return d;
}
long long cal(int n, int m) {
  if (m < 0) return 0;
  if (m == 0) return 1;
  int a1 = 1, b1 = 0;
  for (int i = 0; i < v.size(); i++) {
    long long a = mo[i];
    long long b = cal(n, m, i);
    long long first, second;
    long long d = ex_gcd(a, a1, first, second);
    long long bb = a1 / d;
    first *= (b1 - b) / d;
    first %= bb;
    if (first < 0) first += bb;
    b = a * first + b;
    a = a * a1;
    b %= a;
    a1 = a, b1 = b;
  }
  return b1;
}
int main() {
  int i, m = 0, j, k, K, T, n;
  int l, r, P;
  scanf("%d%d%d%d", &n, &P, &l, &r);
  K = P;
  for (int i = 2; i < 100010 << 1; i++) {
    if (1LL * i * i > P) break;
    if (K % i == 0) {
      k = 0;
      j = 1;
      while (K % i == 0) K /= i, k++, j *= i;
      v.push_back({i, k});
      mo.push_back(j);
    }
  }
  if (K > 1) v.push_back({K, 1}), mo.push_back(K);
  for (int i = 0; i < v.size(); i++) {
    int first = v[i].first, second = v[i].second, q = mo[i];
    f[i][0] = 1;
    for (int j = 1; j < 100010; j++) {
      K = j;
      k = 0;
      while (K % first == 0) K /= first, k++;
      f[i][j] = 1LL * f[i][j - 1] * K % q;
      c[i][j] = c[i][j - 1] + k;
    }
  }
  long long ans = 0;
  for (int i = 0; i < n + 1; i++) {
    m = n - i;
    if (l > m) break;
    int second = min(r, m);
    if ((second & 1) != (m & 1)) second--;
    int first = l;
    if ((first & 1) != (m & 1)) first++;
    if (first <= second) {
      long long w = (cal(m, (m - first) / 2) - cal(m, (m - second) / 2 - 1)) *
                    cal(n, i) % P;
      ans += w;
    }
  }
  ans %= P;
  if (ans < 0) ans += P;
  printf("%d\n", ans);
  return 0;
}