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 JAVA):

Solution:
import java.io.*;
import java.util.*;

public class D896 {
	
	long mod;
	
	long[][] factorial(int n, Long[] prime) {
		int k = prime.length;
		long[][] f = new long[n+1][k+1];
		f[0][0] = 1L;
		for(int i = 1; i <= n; i++) {
			long cur = i;
			for(int j = 0; j <= k; j++) f[i][j] = f[i-1][j];
			for(int j = 0; j < k; j++) {				
				while(cur%prime[j] == 0) {
					cur /= prime[j];
					f[i][j+1]++;
				}
			}
			f[i][0] = (f[i][0] * cur) % mod;
		}
		return f;
	}
	
	long[][] natural(int n, Long[] prime) {
		int k = prime.length;
		long[][] f = new long[n+1][k+1];
		for(int i = 1; i <= n; i++) {
			f[i][0] = 1L;
			long cur = i;
			for(int j = 0; j < k; j++) {				
				while(cur%prime[j] == 0) {
					cur /= prime[j];
					f[i][j+1]++;
				}
			}
			f[i][0] = cur % mod;
		}
		return f;
	}

	Long[] factors(long p){
		LinkedList<Long> f = new LinkedList<Long>();
		long x = 2;
		while(x*x <= p) {
			long y = 0;
			while(p%x == 0) {
				p /= x;
				y++;
			}
			if(y != 0) f.addLast(x);
			x++;
		}
		if(p != 1) f.addLast(p);
		return f.toArray(new Long[0]);
	}

	long[] euclides(long x, long y) {
		if(y == 0) return new long[] {1L,0L};
		if(x == 0) return new long[] {0L,1L};
		long[] res = euclides(y%x, x);
		long a = res[0];
		long b = res[1];
		return new long[] {(b-a*(y/x)), a};
	}

	long inverse(long x) {
		long[] res = euclides(x, mod);
		long a = res[0];
		return ((a%mod)+mod)%mod;
	}


	long modpow(long m, long n) {
		long res = 1%mod;
		while(n > 0){
			if(n % 2 == 1) res = (res*m)%mod;
			m = (m*m)%mod;
			n = n/2;
		}
		return res;
	}
	
	long[][] naturalPrime;
	long[][] facPrime;
	Long[] prime;
	long[] a0;
	long[] al;
	long[] alnext;
	long[] ar;
	long[] arnext;
	
	int n;
	int l;
	int r;
	

	private void solve() throws Exception {
		n = nextInt();
		mod = nextLong();		
		l = nextInt();
		r = nextInt();
		
		prime = factors(mod);
		facPrime = factorial(2*n, prime);
		naturalPrime = natural(2*n, prime);
		long[] C = new long[2*n+1];
		
		for(int i = 0; i <= n; i++) {
			long c = (((facPrime[n][0] * inverse(facPrime[i][0])) % mod) * inverse(facPrime[n-i][0])) % mod;
			for(int j = 0; j < prime.length; j++) {
				c = (c * modpow(prime[j], facPrime[n][j+1] - facPrime[i][j+1] - facPrime[n-i][j+1]))%mod;
			}
			C[i] = c;
		}
		a0 = catalan(n,0);
		al = catalan(n,l-1);
		alnext = catalan(n,l);
		ar = catalan(n,r);
		arnext = catalan(n,r+1);
		
		long[] br = b(r, ar, arnext);
		long[] bl = b(l-1, al, alnext);
		
		
		
		long res = 0;
		for(int i = 0; i <= n; i++) res = (res + (((br[i]-bl[i]+mod)%mod)*C[i])%mod)%mod;
		
		
		out.println(res);
	}
	
	long[] b(int t, long[] at, long[] atnext) {
		long[] res = new long[n+1];
		if(t >= 0) res[0] = 1;
		for(int i = 1; i <= n; i++) {
			res[i] = (2L * res[i-1])%mod;
			res[i] = (res[i] - ((i-t)%2 == 0 ? 0:at[(i+t)/2]) + mod)%mod;
			res[i] = (res[i] + ((i-(t+1))%2 == 0 ? 0:atnext[(i+t+1)/2]) + mod)%mod;
			res[i] = (res[i] - ((i-0)%2 == 0 ? 0: a0[(i+0)/2]) + mod)%mod;
		}
		
		return res;
	}
	
	long[] catalan(int n, int t) {
		long[] res = new long[n+1];
		if(t < 0) return res;
		for(int i = t; i <= n; i++) {
			res[i] = (((((facPrime[2*i-t][0] * inverse(facPrime[i+1][0])) % mod) * inverse(facPrime[i-t][0])) % mod) * naturalPrime[t+1][0]) % mod;
			for(int j = 0; j < prime.length; j++) {
				res[i]  = (res[i] * modpow(prime[j], naturalPrime[t+1][j+1] + facPrime[2*i-t][j+1] - facPrime[i+1][j+1] - facPrime[i-t][j+1]))%mod;
			}
		}
		return res;
	}

	public static void main(String[] args) {
		new D896().run();
	}



	private BufferedReader in;
	private PrintWriter out;
	private StringTokenizer tokenizer;

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			tokenizer = null;
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	private int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	private long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	private float nextFloat() throws IOException {
		return Float.parseFloat(nextToken());
	}

	private String nextLine() throws IOException {
		return new String(in.readLine());
	}

	private String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(in.readLine());
		}
		return tokenizer.nextToken();
	}
}