#C7503. K-th Smallest Number

    ID: 51382 Type: Default 1000ms 256MiB

K-th Smallest Number

K-th Smallest Number

You are given T test cases. For each test case, you are provided with an integer N, an integer k, and an array of N integers. Your task is to determine the k-th smallest number in the array.

For a given test case, let the array be \(A = [a_1, a_2, \dots, a_N]\). After sorting the array in non-decreasing order, the k-th smallest element is \(A_{(k)}\), where \(1 \leq k \leq N\). Note that the arrays may contain large integers, so it is essential to implement an efficient sorting procedure.

Input/Output Specifications are given below.

inputFormat

The first line of input contains a single integer T, representing the number of test cases. Each test case consists of two lines. The first line contains two space-separated integers N and k, where N is the number of elements in the array and k is the order of the smallest element to find. The second line contains N space-separated integers representing the elements of the array.

outputFormat

For each test case, output the k-th smallest number on a new line.## sample

4
5 2
1 5 2 4 3
6 4
7 10 4 3 20 15
4 1
4 2 5 1
3 3
12 3 9
2

10 1 12

</p>