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 MOD = 1e9 + 7;
map<int, int> M;
vector<pair<int, int> > V;
long long F1[12][100010], F2[12][100010];
int p;
int pw(int x, int y, int M) {
  int res = 1;
  while (y) {
    if (y & 1) res = (long long)res * x % M;
    x = (long long)x * x % M;
    y >>= 1;
  }
  return res;
}
long long gc(long long x, long long y) { return y == 0 ? x : gc(y, x % y); }
pair<long long, long long> helper(long long a, long long b) {
  if (!b)
    return pair<long long, long long>(1, 0);
  else {
    pair<long long, long long> c = helper(b, a % b);
    return pair<long long, long long>(c.second, c.first - a / b * c.second);
  }
}
long long my_mul2(long long a, long long b, long long m) { return a * b % m; }
long long DODO(vector<pair<long long, long long> > &L) {
  if (((int)(L).size()) == 0) return 0;
  if (L.size() == 1)
    return L[0].first;
  else {
    pair<long long, long long> a = L.back();
    L.pop_back();
    pair<long long, long long> b = L.back();
    L.pop_back();
    pair<long long, long long> t = helper(a.second, b.second);
    long long g = gc(a.second, b.second);
    if ((b.first - a.first) % g != 0) return -1;
    long long m = b.second / g * a.second;
    long long x =
        (my_mul2((b.first - a.first) / g % m + m, (t.first * a.second % m), m) +
         a.first) %
        m;
    x = (x % m + m) % m;
    L.emplace_back(x, m);
    return DODO(L);
  }
}
int Get(int n, int r) {
  if (r > n) return 0;
  vector<pair<long long, long long> > L;
  for (int i = 0; i < ((int)(V).size()); i++) {
    int p = V[i].first;
    long long px = 1;
    for (int b = 0; b < V[i].second; b++) px = px * p;
    int val = (int)(F1[i][n] - F1[i][r] - F1[i][n - r]);
    long long g = 0;
    if (val >= V[i].second)
      g = 0;
    else {
      int ppx = 1, ppy = 1;
      for (int b = 0; b < V[i].second - val; b++) ppx = ppx * p;
      ppy = ppx / p * (p - 1);
      long long temp = F2[i][n] * pw((int)F2[i][r], ppy - 1, ppx) % ppx *
                       pw((int)F2[i][n - r], ppy - 1, ppx) % ppx;
      g = (int)temp;
      for (int b = 0; b < val; b++) g = g * p;
    }
    L.push_back(pair<long long, long long>(g, px));
  }
  return (int)DODO(L);
}
int Do(int n, int x) {
  if (x < 0) return 0;
  long long res = 0;
  for (int j = 0; j <= n; j++) {
    long long t = Get(n, j);
    long long t2 = Get(n + 1 - j, 1 + j);
    if (n - j + 1 >= x + j + 2) t2 = t2 - Get(n + 1 - j, x + j + 2);
    if (t2 < 0) t2 += p;
    t = t * t2 % p;
    res = (res + t) % p;
  }
  return (int)res;
}
void solve() {
  int n, l, r;
  scanf("%d%d%d%d", &n, &p, &l, &r);
  int tp = p;
  for (int i = 2; (long long)i * i <= tp; i++) {
    while (tp % i == 0) {
      M[i]++;
      tp /= i;
    }
  }
  if (tp > 1) M[tp]++;
  for (pair<int, int> e : M) V.push_back(e);
  int m = ((int)(V).size());
  for (int i = 0; i < m; i++) {
    F1[i][0] = 0;
    F2[i][0] = 1;
    int p = V[i].first;
    int px = 1;
    for (int b = 0; b < V[i].second; b++) px = px * p;
    for (int a = 1; a < 100010; a++) {
      int cnt = 1, ta = a;
      while (ta % p == 0) ++cnt, ta /= p;
      F1[i][a] = F1[i][a - 1] + cnt;
      F2[i][a] = (long long)F2[i][a - 1] * ta % px;
    }
  }
  int ans = Do(n, r) - Do(n, l - 1);
  if (ans < 0) ans += p;
  printf("%d\n", ans);
}
int main() {
  int Tc = 1;
  for (int tc = 1; tc <= Tc; tc++) {
    solve();
  }
  return 0;
}