After huge success in Borhani business, Biswa has recently started restaurant business. He’s got the information about the numbers of customers for days, a sequence of integers . He wants to calculate the popularity of his restaurant from this data. First he’ll choose a window of size (). Then for each K-sized window from the original sequence (first -sized window will contain , second one will contain , and so on), he’ll calculate the number of all possible continuous increasing sequences in it and write them down in order. It’ll create a sequence of integers . Finally he’ll run the following function on the later found sequence:
Output of this function is the popularity that Biswa desires to calculate.
A sequence is increasing if for every two adjacent elements in it, the later one is greater than the previous one. A sequence containing a single element is considered to be a increasing sequence as well.
First line of the test case contains a positive integer () denoting the number of scenarios. For each scenario the first line will contain two positive integers and (). The second line contains a sequence (), where equals to the number of customers on -th day.
For each scenario, output a single integer - the popularity in a separate line. The answer may be large so compute it modulo .
Input | Output |
---|---|
1 4 3 1 2 3 2 | 16 |
In the sample test the sequence is: 1, 2, 3, 2 and the window size is 3. The first window will contain 1, 2, 3 and 6 possible continuous increasing sequences can be found there: , , , , , . Similarly the second window will contain 4 continuous increasing sequences: , , , . So the sequence is: 6, 4 and if we run that function on it we’ll get 16 which is also 16 in modulo . |