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 N = 1e5 + 10;
int n, p, L, R;
int fact[N], ifact[N], expo[N], prime, power;
int expomod(long long int a, long long int e) {
  int ans = 1;
  while (e) {
    if (e & 1) ans = ans * a % power;
    e /= 2;
    a = a * a % power;
  }
  return ans;
}
void chinese(int &r1, int &m1, int r2, int m2) {
  if (m1 < m2) {
    swap(m1, m2);
    swap(r1, r2);
  }
  while (r1 % m2 != r2) r1 += m1;
  m1 *= m2;
}
int comb(int m, int n) {
  if (n < 0 || n > m) return 0;
  int ans = (long long int)fact[m] * ifact[m - n] % power * ifact[n] % power;
  int k = expo[m] - expo[m - n] - expo[n];
  ans = (long long int)ans * expomod(prime, k) % power;
  return ans;
}
int calc(int n, int bal) {
  long long int ans = 0;
  for (int x = 0, y = bal; x + y <= n; x++, y++) {
    ans += (long long int)comb(n, x) * comb(n - x, y) % power;
  }
  ans %= power;
  if (ans < 0) ans += power;
  return ans;
}
void go(int &r, int &m, int p, int pk) {
  int phi = pk - pk / p;
  prime = p;
  power = pk;
  fact[0] = ifact[0] = 1;
  expo[0] = 0;
  for (int i = (int)(1); i < ((int)n + 1); i++) {
    if (i % p == 0) {
      expo[i] = 1 + expo[i / p];
      fact[i] = fact[i / p];
    } else {
      expo[i] = 0;
      fact[i] = i;
    }
  }
  for (int i = (int)(1); i < ((int)n + 1); i++) {
    expo[i] += expo[i - 1];
    fact[i] = (long long int)fact[i] * fact[i - 1] % pk;
    ifact[i] = expomod(fact[i], phi - 1);
  }
  long long int ans = 0;
  for (int i = 0; i < (int)(2); i++) {
    ans += calc(n, L + i);
    ans -= calc(n, R + 1 + i);
  }
  ans %= pk;
  if (ans < 0) ans += pk;
  chinese(r, m, ans, pk);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> p >> L >> R;
  int ans = 0, mod = 1;
  for (int d = 2; d * d <= p; d++) {
    int dk = 1;
    while (p % d == 0) {
      dk *= d;
      p /= d;
    }
    if (dk > 1) go(ans, mod, d, dk);
  }
  if (p > 1) go(ans, mod, p, p);
  cout << ans << endl;
  return 0;
}