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;
map<long long, long long> mp;
long long a[55], b[55], m[55];
bool prime[40005];
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long extgcd(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 1, y = 0;
    return a;
  }
  long long xx, yy;
  long long d = extgcd(b, a % b, xx, yy);
  x = yy, y = xx - (a / b) * yy;
  return d;
}
long long mod_inverse(long long a, long long m) {
  long long x, y;
  if (extgcd(a, m, x, y) != 1) return -1;
  return (x % m + m) % m;
}
pair<long long, long long> congruence(long long a, long long b, long long m) {
  long long d = gcd(a, m);
  if (b % d) return make_pair(0, -1);
  a /= d, b /= d, m /= d;
  return make_pair(b * mod_inverse(a, m) % m, m);
}
pair<long long, long long> SimultaneousCongruence(long long a[], long long b[],
                                                  long long m[], long long n) {
  long long x = 0, M = 1;
  for (int i = 1; i <= n; i++) {
    pair<long long, long long> res =
        congruence(a[i] * M, (b[i] - a[i] * x % m[i] + m[i]) % m[i], m[i]);
    if (res.second == -1) return res;
    x += M * res.first, M *= res.second;
  }
  return make_pair(x, M);
}
const int FACT_MAX = 4000005;
long long q[FACT_MAX], e[FACT_MAX];
long long modpow(long long a, long long n, long long mod) {
  if (n == 0) return 1;
  if (n % 2) {
    return ((a % mod) * (modpow(a, n - 1, mod) % mod)) % mod;
  } else {
    return modpow((a * a) % mod, n / 2, mod) % mod;
  }
}
void make_fact(long long p, long long mod) {
  long long qval = 1, eval = 0;
  q[0] = 1, e[0] = 0;
  for (int i = 1; i < FACT_MAX; i++) {
    long long t = i;
    while (t % p == 0) {
      eval++;
      t /= p;
    }
    qval *= t, qval %= mod;
    q[i] = qval, e[i] = eval;
  }
}
long long comb(long long n, long long k, long long p, long long ex,
               long long mod) {
  long long eval = e[n] - e[k] - e[n - k];
  if (eval >= ex) return 0;
  long long ret = q[n] * mod_inverse(q[k] * q[n - k] % mod, mod) % mod;
  ret *= modpow(p, eval, mod), ret %= mod;
  return ret;
}
long long n, M, l, r;
long long get(long long n, long long r, long long p, long long ex,
              long long mod) {
  if (n % 2 != r % 2) r++;
  if (r > n) return 0;
  long long h = (n - r) / 2;
  long long ret = comb(n, h, p, ex, mod);
  return ret;
}
long long calc(long long p, long long ex, long long mod) {
  make_fact(p, mod);
  long long ret = 0;
  for (long long(i) = (0); (i) <= (n); (i)++) {
    long long tmp =
        get(n - i, l, p, ex, mod) - get(n - i, r + 1, p, ex, mod) + mod;
    tmp *= comb(n, i, p, ex, mod), tmp %= mod;
    ret += tmp, ret %= mod;
  }
  return ret;
}
int main(void) {
  cin >> n >> M >> l >> r;
  for (int i = 2; i < 40005; i++) {
    if (prime[i]) continue;
    for (int j = 2 * i; j < 40005; j += i) prime[j] = true;
  }
  for (int i = 2; i < 40005; i++) {
    if (prime[i]) continue;
    while (M % i == 0) {
      mp[i]++;
      M /= i;
    }
  }
  if (M > 1) mp[M]++;
  long long id = 0;
  for (auto it = mp.begin(); it != mp.end(); it++) {
    id++;
    long long mod = 1;
    for (int i = 0; i < it->second; i++) mod *= it->first;
    a[id] = 1, b[id] = calc(it->first, it->second, mod), m[id] = mod;
  }
  cout << SimultaneousCongruence(a, b, m, id).first << endl;
  return 0;
}