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 N = 100010, M = 12;
long long ans;
int n, mod;
long long cm[M], cx[M], cy[M];
struct comb {
  int mod, phi, p, c, maxn;
  int cj[N], f[N], num[N], fi[N];
  int pow[40];
  int power(int x, int y) {
    int ret = 1;
    for (; y; y >>= 1, x = 1ll * x * x % mod) {
      if (y & 1) ret = 1ll * ret * x % mod;
    }
    return ret;
  }
  void prepare() {
    int i;
    maxn = n;
    cj[0] = 1;
    for (i = 1; i <= maxn; i++)
      cj[i] = (i % p == 0) ? cj[i - 1] : 1ll * cj[i - 1] * i % mod;
    phi = mod / p * (p - 1);
    for (i = 1; i <= maxn; i++) num[i] = num[i / p] + i / p;
    f[0] = 1;
    fi[0] = 1;
    for (i = 1; i <= maxn; i++) {
      if (i < mod)
        f[i] = 1ll * cj[i] * f[i / p] % mod;
      else
        f[i] =
            1ll * power(cj[mod], i / mod) * cj[i % mod] % mod * f[i / p] % mod;
      fi[i] = power(f[i], phi - 1);
    }
    pow[0] = 1;
    for (i = 1; i <= c - 1; i++) pow[i] = pow[i - 1] * p;
  }
  int C(int n, int m) {
    int x = num[n] - num[m] - num[n - m];
    if (x >= c) return 0;
    return 1ll * f[n] * fi[m] % mod * fi[n - m] % mod * pow[x] % mod;
  }
};
comb a[M];
int cnt;
long long C(int n, int m) {
  if (n < m) return 0;
  long long r1, r2, x;
  int i;
  r1 = a[1].C(n, m);
  for (i = 2; i <= cnt; i++) {
    r2 = a[i].C(n, m);
    x = cx[i] * (r2 - r1) % cm[i];
    r1 = (cm[i - 1] * x + r1) % cm[i];
    r1 = (r1 + cm[i]) % cm[i];
  }
  return r1;
}
void exgcd(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return;
  }
  exgcd(b, a % b, y, x);
  y -= a / b * x;
}
void prepare(int mod) {
  int i;
  for (i = 2; i * i <= mod; i++)
    if (mod % i == 0) {
      cnt++;
      a[cnt].p = i;
      a[cnt].mod = 1;
      while (mod % i == 0) {
        a[cnt].c++;
        a[cnt].mod *= i;
        mod /= i;
      }
      a[cnt].prepare();
    }
  if (mod > 1) {
    cnt++;
    a[cnt].p = mod;
    a[cnt].c = 1;
    a[cnt].mod = mod;
    a[cnt].prepare();
  }
  cm[1] = a[1].mod;
  long long x, y;
  for (i = 2; i <= cnt; i++) {
    exgcd(cm[i - 1], a[i].mod, x, y);
    cm[i] = a[i].mod * cm[i - 1];
    cx[i] = (x % a[i].mod + a[i].mod) % a[i].mod;
  }
}
int main() {
  int L, R;
  int i, j, l, r, m;
  scanf("%d%d%d%d", &n, &mod, &L, &R);
  if (mod == 1) {
    printf("0\n");
    return 0;
  }
  prepare(mod);
  for (i = 0; i <= n; i++) {
    m = n - i;
    l = (m + L + 1) / 2;
    r = (m + R) / 2;
    r = min(r, m);
    if (l > r) continue;
    ans = (ans + C(n, m) * (C(m, l) - C(m, r + 1))) % mod;
  }
  ans = (ans + mod) % mod;
  printf("%d\n", (int)ans);
}