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 <typename T>
inline void cmax(T &x, T y) {
  y > x ? x = y : 0;
}
template <typename T>
inline void cmin(T &x, T y) {
  y < x ? x = y : 0;
}
int mod, ss;
inline int add(long long a, long long b) {
  a += b;
  return a >= mod ? a - mod : a;
}
inline int pop(long long a, long long b) {
  a -= b;
  return a < 0 ? a + mod : a;
}
inline int mul(long long a, long long b) { return a * b % mod; }
int qpow(int a, int b) {
  int c = 1;
  while (b) {
    if (b & 1) c = mul(c, a);
    a = mul(a, a);
    b >>= 1;
  }
  return c;
}
const int MAXN = 1e5 + 5;
const int oo = 0x3f3f3f3f;
int fac[MAXN], inv[MAXN], cnt[MAXN], c, d, A, M;
int gcd(int a, int b) { return !b ? a : gcd(b, a % b); }
void exgcd(int a, int b, int &x, int &y) {
  if (!b) {
    x = 1;
    y = 0;
    return;
  }
  exgcd(b, a % b, y, x);
  y -= a / b * x;
}
int Inv(int a) {
  int x, y;
  exgcd(a, mod, x, y);
  return (x % mod + mod) % mod;
}
int C(int a, int b) {
  if (a < 0 || b < 0 || a < b) return 0;
  if (mod == ss) {
    if (a < mod) return mul(fac[a], mul(inv[b], inv[a - b]));
    return mul(C(a / mod, b / mod), C(a % mod, b % mod));
  }
  int res = 1, cnt = 0;
  for (int i = a; i; i /= ss) {
    cnt += i / ss;
    res = mul(res, fac[i]);
  }
  for (int i = b; i; i /= ss) {
    cnt -= i / ss;
    res = mul(res, Inv(fac[i]));
  }
  for (int i = a - b; i; i /= ss) {
    cnt -= i / ss;
    res = mul(res, Inv(fac[i]));
  }
  res = mul(res, qpow(ss, cnt));
  return res;
}
int calc(int n, int l, int r) {
  if (ss == mod) {
    fac[0] = inv[0] = inv[1] = 1;
    for (int i = 1; i <= n; i++) fac[i] = mul(i, fac[i - 1]);
    for (int i = 2; i <= n; i++) inv[i] = mul(mod - mod / i, inv[mod % i]);
    for (int i = 1; i <= n; i++) inv[i] = mul(inv[i], inv[i - 1]);
  } else {
    fac[0] = 1;
    for (int i = 1; i <= n; i++) {
      if (i % ss == 0)
        fac[i] = fac[i - 1];
      else
        fac[i] = mul(i % mod, fac[i - 1]);
    }
  }
  int sum = 0;
  for (int i = 0; i <= n; i++) {
    int dl = l, dr = r, m = n - i;
    cmin(dr, m);
    if (m & 1) {
      if (!(dl & 1)) dl++;
      if (!(dr & 1)) dr--;
    } else {
      if (dl & 1) dl++;
      if (dr & 1) dr--;
    }
    if (dl > dr) {
      sum = add(sum, 0);
      continue;
    }
    int cl = (m + dl) / 2, cr = (m + dr) / 2 + 1;
    sum = add(sum, mul(C(n, i), pop(C(m, cl), C(m, cr))));
  }
  return sum;
}
void CRT(int a, int m) {
  int x, y, c = a - A, d = gcd(-m, M);
  exgcd(M, -m, x, y);
  int t = -m / d;
  x = ((1LL * x * (c / d) % t) + t) % t;
  int tmp = M * m;
  A = ((A + 1LL * x * M) % tmp + tmp) % tmp;
  M = tmp;
}
int main() {
  int n, p, l, r;
  scanf("%d%d%d%d", &n, &p, &l, &r);
  int sq = sqrt(p);
  A = 0;
  M = 1;
  for (int i = 2; i <= sq; i++)
    if (p % i == 0) {
      mod = 1;
      ss = i;
      while (p % i == 0) {
        mod *= i;
        p /= i;
      }
      int a = calc(n, l, r);
      CRT(a, mod);
    }
  if (p > 1) {
    ss = mod = p;
    int a = calc(n, l, r);
    CRT(a, mod);
  }
  printf("%d\n", A);
  return 0;
}