Under construction

Still being built. Things may change

LIS Number

Time limit1sMemory limit1024 MB

Summary
Count the ways to delete elements from a length-N sequence so that its LIS Number equals K, modulo 1,000,000,007.
Level

Medium6 of 10

Topics
Dynamic programming, Prefix sum, Array
Solved
No attempts yet

Problem

The LIS Number of a sequence of integers AA is the smallest positive integer LL such that AA can be obtained by concatenating LL strictly increasing sequences. For example, the LIS Number of A={1,4,4,2,6,3}A = \{1, 4, 4, 2, 6, 3\} is 4. You can get AA as {1,4}+{4}+{2,6}+{3}\{1, 4\} + \{4\} + \{2, 6\} + \{3\}, but not with 3 or fewer sequences. The LIS Number of a strictly increasing sequence is 1.

You are given a sequence of length NN and an integer KK. You want to transform the given sequence into a sequence with LIS Number KK. The only operation you can perform is deleting 0 or more numbers from the original sequence. Count the number of ways to do this. Two ways are different if the sets of removed positions (indices) are different.

Input

The first line contains a positive integer tt, the number of test cases. The first line of each test case contains two integers NN (1≤N≤50,0001 \le N \le 50{,}000) and KK (1≤K≤101 \le K \le 10). The second line contains NN integers of the sequence, separated by single spaces. Each integer is between 0 and 100000, inclusive.

Output

For each test case, output the number of ways to transform the given sequence of length NN into a sequence with LIS Number KK. Since the count can be very large, output it modulo 1,000,000,0071{,}000{,}000{,}007.

Examples1

  1. Example 1

    Input
    4
    5 1
    1 2 3 4 5
    5 1
    1 1 1 1 1
    5 2
    1 1 1 1 1
    5 2
    1 2 3 4 5
    
    Expected output
    31
    5
    10
    0