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 GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
long long MOD = 1000000007;
long double EPS = 1e-9;
long long binpow(long long b, long long p, long long mod) {
  long long ans = 1;
  b %= mod;
  for (; p; p >>= 1) {
    if (p & 1) ans = ans * b % mod;
    b = b * b % mod;
  }
  return ans;
}
void pre() {}
using TP = long long;
TP mod_inv(TP a, TP md) {
  TP b = md, u = 1, v = 0;
  while (b != 0) {
    TP t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= md;
  if (u < 0) u += md;
  return u;
}
namespace Factorize {
using TP = long long;
vector<pair<TP, TP>> PrimeFact(TP x) {
  vector<pair<TP, TP>> ans;
  for (TP i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      TP cnt = 0;
      while (x % i == 0) {
        x /= i;
        cnt++;
      }
      ans.emplace_back(i, cnt);
    }
  }
  if (x > 1) ans.emplace_back(x, 1);
  return ans;
}
vector<TP> Divisors(TP x) {
  vector<TP> ans;
  for (TP i = 1; i * i <= x; i++) {
    if (x % i == 0) {
      ans.emplace_back(i);
      if (x / i != i) ans.emplace_back(x / i);
    }
  }
  return ans;
}
};  // namespace Factorize
using namespace Factorize;
namespace CRT {
using TP = long long;
TP exgcd(TP a, TP b, TP& xcoef, TP& ycoef) {
  if (b == 0) {
    xcoef = 1;
    ycoef = 0;
    return a;
  }
  TP temp, gc = exgcd(b, a % b, xcoef, ycoef);
  temp = ycoef;
  ycoef = xcoef - (a / b) * ycoef;
  xcoef = temp;
  return gc;
}
bool crt(vector<TP>& a, vector<TP>& b, vector<TP>& m, TP& x, TP& M) {
  long long n = b.size();
  x = 0;
  M = 1;
  for (long long i = 0; i < n; i++) {
    long long a_ = a[i] * M, b_ = b[i] - a[i] * x, m_ = m[i];
    long long y, t, g = exgcd(a_, m_, y, t);
    if (b_ % g) return false;
    b_ /= g;
    m_ /= g;
    x += M * (y * b_ % m_);
    M *= m_;
  }
  x = (x + M) % M;
  return true;
}
pair<TP, TP> getSol(vector<pair<TP, TP>>& arr) {
  vector<TP> a, b, m;
  TP x, M;
  for (auto v : arr) {
    a.emplace_back(1);
    b.emplace_back(v.first);
    m.emplace_back(v.second);
  }
  bool pos = crt(a, b, m, x, M);
  if (pos)
    return make_pair(x, M);
  else
    return make_pair(-1, -1);
}
}  // namespace CRT
using namespace CRT;
struct ncrAdvanced1 {
  struct NcR_PtoK {
    TP curP, curK, curMD;
    vector<TP> cnt, fact, rfact;
    NcR_PtoK(TP _curP, TP _curK, TP MAXN = 400400) {
      curP = _curP;
      curK = _curK;
      curMD = 1;
      for (int i = 0; i < curK; i++) curMD *= curP;
      cnt.resize(MAXN);
      fact.resize(MAXN);
      rfact.resize(MAXN);
      cnt[0] = 0;
      fact[0] = 1;
      rfact[0] = 1;
      for (TP i = 1; i < MAXN; i++) {
        TP val = i, c = 0;
        while (val % curP == 0) {
          val /= curP;
          c++;
        }
        fact[i] = fact[i - 1] * val % curMD;
        cnt[i] = cnt[i - 1] + c;
      }
      rfact[MAXN - 1] = mod_inv(fact[MAXN - 1], curMD);
      for (TP i = MAXN - 2; i >= 1; i--) {
        TP val = i + 1;
        while (val % curP == 0) val /= curP;
        rfact[i] = rfact[i + 1] * val % curMD;
      }
    }
    TP nCr(long long n, long long r) {
      if (n < 0 || r < 0 || r > n) return 0;
      TP curpow = cnt[n] - cnt[n - r] - cnt[r];
      if (curpow > curK) return 0;
      TP res = (fact[n] * rfact[n - r]) % curMD;
      res = res * rfact[r] % curMD;
      for (int i = 0; i < curpow; i++) res = res * curP % curMD;
      return res;
    }
  };
  vector<NcR_PtoK> Table;
  vector<pair<TP, TP>> primer;
  ncrAdvanced1(long long P, long long MAXN = 400400) {
    primer = PrimeFact(P);
    for (auto v : primer) {
      Table.emplace_back(NcR_PtoK(v.first, v.second, MAXN));
    }
  }
  long long nCr(long long n, long long r) {
    if (n < 0 || r < 0 || r > n) return 0;
    vector<pair<TP, TP>> vals;
    for (int i = 0; i < (int)primer.size(); i++) {
      vals.emplace_back(Table[i].nCr(n, r), Table[i].curMD);
    }
    return getSol(vals).first;
  }
  long long calculateValue(long long n, long long l, long long r) {
    vector<pair<TP, TP>> vals;
    for (int i = 0; i < (int)primer.size(); i++) {
      long long md = Table[i].curMD;
      long long res = 0;
      for (long long x = n; x >= l; x--) {
        long long ans = Table[i].nCr(n, x);
        int lb = max((x - r + 1) / 2, 0LL) - 1, ub = (x - l) / 2;
        ans *= (Table[i].nCr(x, ub) + md - Table[i].nCr(x, lb)) % md;
        ans %= md;
        res = (res + ans) % md;
      }
      vals.emplace_back(res, md);
    }
    return getSol(vals).first;
  }
};
void solve() {
  long long n, p, l, r;
  cin >> n >> p >> l >> r;
  ncrAdvanced1 Bino(p);
  cout << Bino.calculateValue(n, l, r) << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  pre();
  long long _t = 1;
  for (long long i = 1; i <= _t; i++) {
    solve();
  }
}