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;
int n, l, r;
long long p;
long long mod, bs, expo;
pair<long long, long long> gcd(long long a, long long b) {
  if (a == 0) {
    return make_pair(0, 1);
  }
  pair<long long, long long> prev = gcd(b % a, a);
  return make_pair(prev.second - (b / a) * prev.first, prev.first);
}
long long modInv(long long x) {
  pair<long long, long long> res = gcd(x, mod);
  res.first = (res.first + mod) % mod;
  return res.first;
}
long long modDiv(long long x, long long y) { return (x * modInv(y)) % mod; }
pair<long long, long long> fac[100005];
void getFacs() {
  fac[0] = {1, 0};
  for (int i = (1); i <= (signed)(100005 - 1); i++) {
    fac[i] = fac[i - 1];
    int tmp = i;
    while (tmp % bs == 0) {
      fac[i].second++;
      tmp /= bs;
    }
    fac[i].first = (fac[i].first * tmp) % mod;
  }
}
long long modExp(long long b, long long ex) {
  long long prod = 1;
  while (ex > 0) {
    if (ex % 2 == 0) {
      b = (b * b) % mod;
      ex /= 2;
    } else {
      prod = (prod * b) % mod;
      ex--;
    }
  }
  return prod;
}
long long choose(int a, int b) {
  int c = a - b;
  if (c < 0) {
    cout << "ur bad\n";
    exit(0);
  }
  long long bsp = fac[a].second - fac[b].second - fac[c].second;
  long long res = modDiv(fac[a].first, (fac[b].first * fac[c].first) % mod);
  if (bsp >= expo) return 0;
  for (int _ = 0; _ < (signed)(bsp); _++) res = (res * bs) % mod;
  return res;
}
long long calc(int n, int l, int r) {
  if (r > n) r = n;
  if (l > n) return 0;
  if ((n - r) % 2) --r;
  if ((n - l) % 2) ++l;
  long long ret =
      choose(n, (n - l) / 2) - (n == r ? 0 : choose(n, (n - r) / 2 - 1));
  return ret < 0 ? ret + mod : ret;
}
map<long long, long long> res;
long long calc2() {
  getFacs();
  long long sm = 0;
  for (int i = (0); i <= (signed)(n); i++) {
    long long p1 = calc(n - i, l, r);
    long long p2 = choose(n, i);
    sm = (sm + p1 * p2) % mod;
  }
  return sm;
}
int main() {
  cin >> n >> p >> l >> r;
  long long op = p;
  for (int i = 2; 1LL * i * i <= p; ++i) {
    if (p % i != 0) continue;
    int cnt = 0;
    long long ree = 1;
    while (p % i == 0) {
      ++cnt;
      p /= i;
      ree *= i;
    }
    mod = ree;
    bs = i;
    expo = cnt;
    long long ans = calc2();
    res[mod] = ans;
  }
  if (p != 1) {
    mod = p;
    bs = p;
    expo = 1;
    long long ans = calc2();
    res[mod] = ans;
  }
  long long fin = 0;
  for (auto u : res) {
    pair<long long, long long> hmm = gcd(u.first, op / u.first);
    long long got = ((u.second * hmm.second) % op * (op / u.first)) % op;
    fin = (fin + got) % op;
  }
  cout << (fin + op) % op << "\n";
  return 0;
}