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>
#pragma comment(linker, "/STACK:512000000")
using namespace std;
void solve(bool);
void precalc();
clock_t start;
int main() {
  start = clock();
  int t = 1;
  cout.sync_with_stdio(0);
  cin.tie(0);
  precalc();
  cout.precision(10);
  cout << fixed;
  int testNum = 1;
  while (t--) {
    solve(true);
  }
  cout.flush();
  return 0;
}
template <typename T>
T binpow(T q, T w, T mod) {
  if (!w) return 1 % mod;
  if (w & 1) return q * 1LL * binpow(q, w - 1, mod) % mod;
  return binpow(q * 1LL * q % mod, w / 2, mod);
}
template <typename T>
T gcd(T q, T w) {
  while (w) {
    q %= w;
    swap(q, w);
  }
  return q;
}
template <typename T>
T lcm(T q, T w) {
  return q / gcd(q, w) * w;
}
template <typename T>
void make_unique(vector<T>& a) {
  sort(a.begin(), a.end());
  a.erase(unique(a.begin(), a.end()), a.end());
}
template <typename T>
void relax_min(T& cur, T val) {
  cur = min(cur, val);
}
template <typename T>
void relax_max(T& cur, T val) {
  cur = max(cur, val);
}
void precalc() {}
const long long C = 100500;
long long mod;
long long phi;
long long rem[C];
long long rev_rem[C];
vector<long long> primes, degs;
long long n;
long long get_deg(long long n, long long p) {
  long long res = 0;
  while (n) {
    res += n / p;
    n /= p;
  }
  return res;
}
long long getC(long long n, long long k) {
  if (n < k) {
    return 0;
  }
  long long res = rem[n] * rev_rem[k] % mod * rev_rem[n - k] % mod;
  for (long long i = 0; i < primes.size(); ++i) {
    long long deg = get_deg(n, primes[i]) - get_deg(k, primes[i]) -
                    get_deg(n - k, primes[i]);
    res = res * binpow(primes[i], deg, mod) % mod;
  }
  return res;
}
long long get_res(long long l) {
  long long res = 0;
  for (long long par = 0; par < 2; ++par) {
    for (long long cur = 0; 2 * cur + par <= n; ++cur) {
      long long m = 2 * cur + par;
      long long cur_l = l;
      if ((cur_l + par) % 2) {
        ++cur_l;
      }
      long long now_c = (m + cur_l) / 2;
      res += getC(n, m) * getC(m, now_c);
      res %= mod;
    }
  }
  return res;
}
void solve(bool read) {
  long long l, r;
  cin >> n >> mod >> l >> r;
  rem[0] = 1;
  long long M = mod;
  phi = mod;
  for (long long p = 2; p * p <= M; ++p) {
    if (M % p == 0) {
      phi = phi * (p - 1) / p;
      primes.push_back(p);
      degs.push_back(0);
      while (M % p == 0) {
        M /= p;
        ++degs.back();
      }
    }
  }
  if (M > 1) {
    phi = phi * (M - 1) / M;
    primes.push_back(M);
    degs.push_back(1);
  }
  for (long long i = 1; i < C; ++i) {
    long long cur = i;
    for (long long p : primes) {
      while (cur % p == 0) {
        cur /= p;
      }
    }
    rem[i] = rem[i - 1] * cur % mod;
  }
  for (long long i = 0; i < C; ++i) {
    rev_rem[i] = binpow(rem[i], phi - 1, mod);
  }
  long long res = get_res(l) - get_res(r + 1);
  res %= mod;
  if (res < 0) {
    res += mod;
  }
  cout << res << endl;
}