Maximized Subset

No attempts yetTime limit1sMemory limit128 MB

Problem

For a multiset AA (a set whose elements may repeat), define the function f(A)f(A) as follows: f(A)f(A) is the largest integer xx such that every integer from 11 to xx can be written as the sum of the elements of some sub-multiset of AA, while x+1x + 1 cannot be written as such a sum. (A sub-multiset is itself a multiset, so each element may be used only as many times as it appears in AA.)

You are given a multiset AA with nn elements. Choose kk of its elements to form a sub-multiset BB so that f(B)f(B) is as large as possible, and report that maximum value of f(B)f(B).

Input

The first line contains an integer tt (1t1001 \le t \le 100), the number of test cases. Each test case consists of two lines. The first line contains two integers nn and kk (1kn1051 \le k \le n \le 10^5). The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n (1ai1091 \le a_i \le 10^9), separated by single spaces, the elements of AA.

The sum of nn over all test cases does not exceed 10610^6.

Output

For each test case, print on its own line a single integer: the maximum possible value of f(B)f(B).