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 n, p, l, r;
long long p0[25], pu[25], re[25];
long long mul[25][200005];
long long g[200005][25];
int cnt = 0;
void make_init() {
  long long tempp = p;
  for (long long i = 2; i * i <= p; i++) {
    if (p % i == 0) {
      cnt++, p0[cnt] = i, pu[cnt] = 1;
      while (p % i == 0) pu[cnt] *= i, p /= i;
    }
  }
  if (p != 1) cnt++, p0[cnt] = pu[cnt] = p;
  p = tempp;
}
void init() {
  for (long long i = 1; i <= cnt; i++) {
    mul[i][0] = 1;
    for (long long j = 1; j <= pu[i] && j <= 100000; j++) {
      if (j % p0[i])
        mul[i][j] = mul[i][j - 1] * j % pu[i];
      else
        mul[i][j] = mul[i][j - 1];
    }
  }
}
long long pow_mul(long long x, long long y, long long mode) {
  long long ret = 1;
  while (y) {
    if (y & 1) ret = ret * x % mode;
    x = x * x % mode, y >>= 1;
  }
  return ret;
}
void ex_gcd(long long a, long long b, long long &x, long long &y) {
  if (!b) {
    x = 1;
    y = 0;
    return;
  }
  ex_gcd(b, a % b, x, y);
  long long t = x;
  x = y, y = t - (a / b) * x;
}
long long get_inv(long long x, long long y) {
  long long xx, yy;
  ex_gcd(x, y, xx, yy);
  return (xx % y + y) % y;
}
long long calp(long long x, long long i) {
  long long ret = 0;
  x /= p0[i];
  while (x) ret += x, x /= p0[i];
  return ret;
}
long long calc(long long x, long long i) {
  if (g[x][i]) return g[x][i];
  if (!x) return 1;
  if (pu[i] == 4)
    return g[x][i] = pow_mul(3, x / pu[i], pu[i]) * mul[i][x % pu[i]] % pu[i] *
                     calc(x / p0[i], i) % pu[i];
  else if (p0[i] == 2)
    return g[x][i] = mul[i][x % pu[i]] % pu[i] * calc(x / p0[i], i) % pu[i];
  else
    return g[x][i] = pow_mul(pu[i] - 1, x / pu[i], pu[i]) * mul[i][x % pu[i]] %
                     pu[i] * calc(x / p0[i], i) % pu[i];
}
long long ex_lucas(long long x, long long y, long long i) {
  long long mi = calp(x, i) - calp(y, i) - calp(x - y, i);
  return pow_mul(p0[i], mi, pu[i]) * calc(x, i) % pu[i] *
         get_inv(calc(y, i), pu[i]) % pu[i] * get_inv(calc(x - y, i), pu[i]) %
         pu[i];
}
long long china() {
  long long ans = 0;
  for (int i = 1; i <= cnt; i++) {
    long long pp = p / pu[i];
    long long xx, yy;
    ex_gcd(pp, pu[i], xx, yy);
    xx = (xx % pu[i] + pu[i]) % pu[i];
    ans = (ans + xx * re[i] % p * pp % p) % p;
  }
  return ans;
}
long long solve(long long x, long long y) {
  for (int i = 1; i <= cnt; i++) re[i] = ex_lucas(x, y, i);
  return china();
}
int main() {
  scanf("%lld%lld%lld%lld", &n, &p, &l, &r);
  make_init(), init();
  long long S = 0;
  for (long long i = 0; i <= n; i++) {
    if (n - i < l) continue;
    long long v1 = solve(n - i, (n - i - l) / 2);
    long long v2;
    if (n - i - r < 1)
      v2 = 0;
    else
      v2 = solve(n - i, (n - i - r - 1) / 2);
    long long v3 = solve(n, i);
    S = (S + (v1 + p - v2) % p * v3 % p) % p;
  }
  printf("%lld\n", S);
  return 0;
}