Stock Purchase Plan

For each test case, decide whether the daily prices contain a strictly increasing subsequence of length K.

Medium4Dynamic programmingBinary searchInterviewNo attempts yetTime limit5sMemory limit512 MB

Problem

On the way to work you picked a strange document out of a subway station trash can. It listed one company's stock price day by day, and every date was in the future. You compared the listed values with the real prices and they matched exactly. Maybe a descendant rode a time machine back to help an ancestor.

The stock price for the next NN days is given as NN integers. You have never traded stock before, so you go to a brokerage and open an account. To avoid suspicion about trading with knowledge of the future, you decide to buy the stock exactly KK times. You may buy at most once a day, so you buy on KK different days.

To reduce suspicion further, every purchase after the first one must happen on a day whose price is higher than the price on the day of the previous purchase. For example, suppose the prices over 10 days are the following.

Day12345678910
Price10050709075871057811060

If K=3K = 3, buying on days 2, 3 and 4 gives prices 50, 70, 90, which satisfies the condition. If K=6K = 6, buying on days 2, 3, 5, 6, 7 and 9 gives prices 50, 70, 75, 87, 105, 110, which satisfies the condition. If K=10K = 10, no choice of days satisfies the condition.

Given NN, KK and the prices of the NN days, write a program that decides whether the purchases can be made under this condition.

Input

The first line contains the number of test cases TT (2T1002 \le T \le 100). The TT test cases follow in order.

The first line of each test case contains two integers NN and KK. NN is the number of days whose price you know in advance (1N100001 \le N \le 10000), and KK is the number of purchases (1K100001 \le K \le 10000). The next line contains the prices of the NN days in date order, separated by spaces. Every price is an integer between 1 and 10000.

Output

Print two lines for each test case.

The first line contains Case #t, where tt is the test case number counted from 1. The second line contains 1 if the purchases can be made under the condition, and 0 otherwise.