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;
vector<pair<pair<int, int>, vector<int>>> lst;
vector<int> fact;
pair<int, vector<int>> tmp, _tmp;
void init(int p) {
  fact.clear();
  int i;
  for (i = 2; i * i <= p; i++) {
    if (p % i == 0) {
      fact.push_back(i);
      while (p % i == 0) p /= i;
    } else
      ;
  }
  if (p != 1)
    fact.push_back(p);
  else
    ;
}
long long calc(int n, int m, int a, int b, int p) {
  int i, x, y, j;
  tmp.first = lst[n].first.first * (long long)lst[m].first.second % p;
  tmp.second.clear();
  for (i = 0; i < fact.size(); i++) {
    tmp.second.push_back(lst[n].second[i] - lst[m].second[i]);
  }
  _tmp = tmp;
  int a1 = (n - m + a) / 2;
  int a2 = (n - m - a) / 2;
  int b1 = (n - m + b) / 2;
  int b2 = (n - m - b) / 2;
  for (i = 0; i < fact.size(); i++) {
    if (a1 >= 0 && a2 >= 0)
      tmp.second[i] -= lst[a1].second[i] + lst[a2].second[i];
    if (b1 >= 0 && b2 >= 0)
      _tmp.second[i] -= lst[b1].second[i] + lst[b2].second[i];
  }
  if (a1 < 0 || a2 < 0)
    x = 0;
  else {
    tmp.first = tmp.first * (long long)lst[a1].first.second % p *
                (long long)lst[a2].first.second % p;
    for (x = tmp.first, i = 0; i < fact.size(); i++) {
      for (j = tmp.second[i]; j > 0; j--) {
        x = (long long)x * fact[i] % p;
      }
    }
  }
  if (b1 < 0 || b2 < 0)
    y = 0;
  else {
    _tmp.first = _tmp.first * (long long)lst[b1].first.second % p *
                 (long long)lst[b2].first.second % p;
    for (y = _tmp.first, i = 0; i < fact.size(); i++) {
      for (j = _tmp.second[i]; j > 0; j--) {
        y = (long long)y * fact[i] % p;
      }
    }
  }
  return ((x - y) % p + (long long)p) % p;
}
void exgcd(int &x, int &y, int a, int b, int p) {
  if (b == 0) {
    y = 0;
    x = 1;
    return;
  }
  exgcd(x, y, b, a % b, p);
  int _x = x;
  x = y;
  y = ((_x - (a / b) * (long long)x % p) % p + (long long)p) % p;
}
void mklst(int n, int p) {
  int i, k, j, x, y;
  lst.clear();
  lst.resize(1);
  lst[0].first = {1, 1};
  lst[0].second.clear();
  lst[0].second.resize(fact.size(), 0);
  for (i = 1; i <= n; i++) {
    lst.push_back(lst.back());
    k = i;
    for (j = fact.size() - 1; ~j; j--) {
      for (; k % fact[j] == 0; k /= fact[j], lst[i].second[j]++)
        ;
    }
    k = (long long)k * lst.back().first.first % p;
    exgcd(x, y, k, p, p);
    lst[i].first = {k, x};
  }
}
int main() {
  int n, l, r, p;
  scanf("%d%d%d%d", &n, &p, &l, &r);
  init(p);
  long long sum = 0LL;
  mklst(n, p);
  int m, nl, nr;
  for (m = 0; m <= n; m++) {
    if ((n - m - l) & 1)
      nl = l + 1;
    else
      nl = l;
    if ((n - m - r) & 1)
      nr = r - 1;
    else
      nr = r;
    if (nl > nr)
      ;
    else {
      sum += calc(n, m, nl, nr + 2, p);
      sum %= p;
    }
  }
  printf("%lld\n", sum);
  return 0;
}