Alice has a warehouse with n boxes and the ith box has number pi. All box numbers are different and range from 1 to n. Alice wants to rearrange the boxes in the following way:
You are given m triplets Li,Ri,Xi. For each of them, Alice asks you to tell how many different sequences of boxes she can get by selecting the following values.
Since these numbers can be very large, you need to subtract the remainder of their division by the prime number 109+7.
Note: Two sequences of boxes are considered different if there is a position in which the boxes in both sequences have a different number.
Input format
Output format
Print m lines where the ith line contains the remainder of dividing the number of possible sequences for the ith triple by 109+7.
Constraints
1≤n,m≤105
1≤pi≤n
1≤Li≤Ri≤n
1≤Xi≤n
In the first case:
For the first query, result = 2 because it can be swapped 2 and 4.
For the second query, result = 1 because we cannot change any two elements and it turns out that we have only one sequence
For the third query, result = 2 because it can be swapped 2 and 4.
For the fourth query, result = 6 because any two adjacent elements can be swapped.