Limits 3s, 512 MB

After huge success in Borhani business, Biswa has recently started restaurant business. He’s got the information about the numbers of customers for NN days, a sequence of NN integers a1,a2,,aNa_1, a_2, …, a_N. He wants to calculate the popularity of his restaurant from this data. First he’ll choose a window of size KK (KNK ≤ N). Then for each K-sized window from the original sequence (first KK-sized window will contain a1,a2,,aKa_1, a_2, …, a_K, second one will contain a2,a3,,aK+1a_2, a_3, …, a_{K+1}, 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 NK+1N - K + 1 integers b1,b2,,bNK+1b_1, b_2, …, b_{N-K+1}. 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.

Input

First line of the test case contains a positive integer TT (0<T100 < T ≤ 10) denoting the number of scenarios. For each scenario the first line will contain two positive integers NN and KK (1KN1051 ≤ K ≤ N ≤ 10^5). The second line contains a sequence a1,a2,,aNa_1, a_2, …, a_N (1ai1051 ≤ a_i ≤ 10^5), where aia_i equals to the number of customers on ii-th day.

Output

For each scenario, output a single integer - the popularity in a separate line. The answer may be large so compute it modulo 109+710^9+7.

Sample

InputOutput
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: {1,2,3}\{1, 2, 3\}, {1,2}\{1, 2\}, {2,3}\{2, 3\}, {1}\{1\}, {2}\{2\}, {3}\{3\}. Similarly the second window will contain 4 continuous increasing sequences: {2,3}\{2, 3\}, {2}\{2\}, {3}\{3\}, {2}\{2\}. So the sequence bb is: 6, 4 and if we run that function on it we’ll get 16 which is also 16 in modulo 109+710^9+7.


Submit

Login to submit.

Statistics

95% Solution Ratio
shahriar_sustEarliest, May '18
ash_98Fastest, 0.0s
ash_98Lightest, 2.4 MB
serotoninShortest, 1182B
Toph uses cookies. By continuing you agree to our Cookie Policy.