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 <class T>
void splitstr(const string &s, vector<T> &out) {
  istringstream in(s);
  out.clear();
  copy(istream_iterator<T>(in), istream_iterator<T>(), back_inserter(out));
}
static void redirect(int argc, const char **argv) {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  if (argc > 1) {
    static filebuf f;
    f.open(argv[1], ios::in);
    cin.rdbuf(&f);
    if (!cin) {
      cerr << "Failed to open '" << argv[1] << "'" << endl;
      exit(1);
    }
  }
  if (argc > 2) {
    static filebuf f;
    f.open(argv[2], ios::out | ios::trunc);
    cout.rdbuf(&f);
    if (!cout) {
      cerr << "Failed to open '" << argv[2] << "'" << endl;
    }
  }
}
template <typename T>
static T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <typename T>
static T mod(T a, T m) {
  a %= m;
  if (a < 0) a += m;
  return a;
}
template <typename T>
static T inverse(T a, T m) {
  a = mod(a, m);
  if (a <= 1) return a;
  return mod((1 - inverse(m, a) * m) / a, m);
}
static long long P;
static vector<long long> F;
static long long pmod(long long a, long long b) {
  if (b == 0)
    return 1;
  else if (b & 1)
    return a * pmod(a, b - 1) % P;
  else {
    long long t = pmod(a, b / 2);
    return t * t % P;
  }
}
struct number {
  long long rel;
  array<int, 10> ex;
  number() : rel(1), ex{{}} {}
  number operator*(const number &b) const {
    number out;
    out.rel = rel * b.rel % P;
    for (int i = 0; i < ((long long)(F).size()); i++)
      out.ex[i] = ex[i] + b.ex[i];
    return out;
  }
  number operator/(const number &b) const {
    number out;
    out.rel = rel * inverse(b.rel, P) % P;
    for (int i = 0; i < ((long long)(F).size()); i++)
      out.ex[i] = ex[i] - b.ex[i];
    return out;
  }
  long long eval() const {
    long long ans = rel;
    for (int i = 0; i < ((long long)(F).size()); i++) {
      long long f = pmod(F[i], ex[i]);
      ans = ans * f % P;
    }
    return ans;
  }
};
static vector<long long> factors(int P) {
  int s = int(sqrt(P) + 1);
  vector<long long> ans;
  for (int i = 2; i <= s; i++) {
    if (P % i == 0) {
      ans.push_back(i);
      while (P % i == 0) P /= i;
    }
  }
  if (P > 1) ans.push_back(P);
  return ans;
}
int main(int argc, const char **argv) {
  redirect(argc, argv);
  long long N, l, r;
  cin >> N >> P >> l >> r;
  F = factors(P);
  vector<int> d1(N + 1, -1);
  for (int i = 0; i < ((long long)(F).size()); i++)
    for (int j = F[i]; j <= N; j += F[i]) d1[j] = i;
  vector<number> fact(N + 1);
  for (int i = 2; i <= N; i++) {
    number cur;
    long long rel = i;
    while (d1[rel] != -1) {
      cur.ex[d1[rel]]++;
      rel /= F[d1[rel]];
    }
    cur.rel = rel % P;
    assert(gcd(rel, P) == 1);
    fact[i] = fact[i - 1] * cur;
  }
  auto choose = [&](long long n, long long r) {
    number ans = fact[n] / (fact[r] * fact[n - r]);
    return ans.eval();
  };
  long long ans = 0;
  for (int k = l; k <= N; k++) {
    long long x = (k - l) / 2;
    long long y = (k - r + 1) / 2;
    long long term = choose(k, x);
    if (y > 0) term -= choose(k, y - 1);
    term %= P;
    term = term * choose(N, k) % P;
    ans = (ans + term) % P;
  }
  ans %= P;
  if (ans < 0) ans += P;
  cout << ans << '\n';
  return 0;
}