Queue of Soldiers

Count distinct lineups of soldiers with given heights where exactly K soldiers have a strictly shorter soldier ahead of them.

Hard8CombinatoricsDynamic programmingSortingNo attempts yetTime limit5sMemory limit256 MB

Problem

On a planet far from Earth, Bitland and Byteland are at war. The queen of Bitland commands NN soldiers. She has found the weakest point on Byteland's border, but to reach it her soldiers must form a single line and walk through a narrow valley.

Byteland has installed a defense device in the valley. Once a soldier of height vv passes through, every soldier behind that one whose height is strictly greater than vv is shot down. Put another way, a soldier dies exactly when at least one soldier standing earlier in the line is strictly shorter. The soldier at the front always survives.

The queen knows this. She cannot always send her soldiers in non-increasing order of height so that nobody dies, so some soldiers have to die. To find the best line, she asks you to count the arrangements of her soldiers' heights in which exactly KK soldiers die in the valley.

Arrangement XX differs from arrangement YY if there is an index ii (1iN1 \le i \le N) at which the height of the ii-th soldier differs between them.

Input

The first line contains the number of test cases TT (1T201 \le T \le 20).

Each test case consists of two lines. The first line contains two integers NN (1N500001 \le N \le 50000) and KK (0K10000 \le K \le 1000). The second line contains the heights of the NN soldiers, separated by spaces. Every height is a positive integer, at most 100 distinct height values appear, and at most 1000 soldiers share the same height.

Output

For each test case, print one line in the form Case x: y, where xx is the case number starting from 1 and yy is the number of arrangements in which exactly KK soldiers die. The value of yy can be very large, so print it modulo 10000000071000000007.