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;
template <typename T, typename U>
inline void smin(T &a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
  if (a < b) a = b;
}
template <class T>
inline void gn(T &first) {
  char c, sg = 0;
  while (c = getchar(), (c > '9' || c < '0') && c != '-')
    ;
  for ((c == '-' ? sg = 1, c = getchar() : 0), first = 0; c >= '0' && c <= '9';
       c = getchar())
    first = (first << 1) + (first << 3) + c - '0';
  if (sg) first = -first;
}
template <class T, class T1>
inline void gn(T &first, T1 &second) {
  gn(first);
  gn(second);
}
template <class T, class T1, class T2>
inline void gn(T &first, T1 &second, T2 &z) {
  gn(first);
  gn(second);
  gn(z);
}
template <class T>
inline void print(T first) {
  if (first < 0) {
    putchar('-');
    return print(-first);
  }
  if (first < 10) {
    putchar('0' + first);
    return;
  }
  print(first / 10);
  putchar(first % 10 + '0');
}
template <class T>
inline void printsp(T first) {
  print(first);
  putchar(' ');
}
template <class T>
inline void println(T first) {
  print(first);
  putchar('\n');
}
template <class T, class U>
inline void print(T first, U second) {
  printsp(first);
  println(second);
}
template <class T, class U, class V>
inline void print(T first, U second, V z) {
  printsp(first);
  printsp(second);
  println(z);
}
int power(int a, int b, int m, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % m)
    if (b & 1) ans = 1LL * ans * a % m;
  return ans;
}
int mod, mod1, phi;
pair<int, int> f[101010];
int inv(int u) { return power(u, phi - 1, mod1); }
pair<int, int> operator*(const pair<int, int> &a, int b) {
  int c = 0;
  while (b % mod == 0) b /= mod, c++;
  return make_pair((long long)a.first * b % mod1,
                   min(a.second + c, 0x3f3f3f3f));
}
pair<int, int> operator/(const pair<int, int> &a, int b) {
  int c = 0;
  while (b % mod == 0) b /= mod, c++;
  return make_pair((long long)a.first * inv(b) % mod1, a.second - c);
}
pair<int, int> operator*(const pair<int, int> &a, const pair<int, int> &b) {
  return make_pair((long long)a.first * b.first % mod1, a.second + b.second);
}
pair<int, int> operator/(const pair<int, int> &a, const pair<int, int> &b) {
  return make_pair((long long)a.first * inv(b.first) % mod1,
                   a.second - b.second);
}
long long C(int n, int k) {
  pair<int, int> a = f[n] / (f[k] * f[n - k]);
  return (long long)a.first * power(mod, a.second, mod1) % mod1;
}
int dp(int n, int k) {
  if (n < k) return 0;
  if (n == k) return 1;
  if (n + k & 1) return 0;
  int t = n - k >> 1;
  return (C(n, t) + mod1 - C(n, t - 1)) % mod1;
}
int main() {
  int n, p, l, r;
  gn(n, p);
  gn(l, r);
  if (p == 1) return puts("0");
  vector<pair<int, int> > fac;
  int q = p;
  for (int i = 2; i * i <= q; i++)
    if (q % i == 0) {
      int cnt = 0;
      while (q % i == 0) q /= i, cnt++;
      fac.push_back(pair<int, int>(i, cnt));
    }
  if (q > 1) fac.push_back(pair<int, int>(q, 1));
  int ans = 0;
  for (int i = 0; i < fac.size(); i++) {
    mod = fac[i].first;
    int mid = 1, res = 0;
    for (int j = 0; j < fac[i].second; j++) mid *= mod;
    mod1 = mid;
    phi = mid - mid / mod;
    f[0] = pair<int, int>(1, 0);
    for (int j = 1; j <= n; j++) f[j] = f[j - 1] * j;
    long long pre = l == 0;
    res = (res + (long long)C(n, 0) * pre) % mod1;
    for (int t = 0; t < n; t++) {
      pre = pre * 2LL - dp(t, l);
      pre -= dp(t, r);
      pre = pre + dp(t, r + 1);
      if (l) pre = pre + dp(t, l - 1);
      pre = (pre % mod1 + mod1) % mod1;
      res = (res + (long long)C(n, t + 1) * pre) % mod1;
    }
    ans = (ans + (long long)res * (p / mid) % p * inv(p / mid)) % p;
  }
  println(ans);
  return 0;
}