The Stirling number of the first kind [n k] is the number of permutations of n elements with exactly k disjoint cycles. The well-known recurrence relation is defined as follows: [n+1 k]=n[n k]+[n k−1] for k>0, with the initial conditions
[0 0 ]=1and[n 0]=[0 n]=0 for n>0.
Given four integers, n, l, r, and p, find the value of (∑_k=lr[n k])modp where p is prime.
The first line contains four integers, n, l, r, and p (1≤n≤1018, 0≤l≤r≤n, 2≤p≤106, p is prime).
Output an integer denoting the answer.