#C862. K-th Smallest Element

    ID: 52622 Type: Default 1000ms 256MiB

K-th Smallest Element

K-th Smallest Element

Given an array of integers, your task is to find the k\text{th} smallest element in the array. Formally, if you sort the array in non-decreasing order as \(A\), the answer is \(A[k-1]\). You will be given multiple test cases; for each test case, you must output the corresponding kth smallest element.

Note: The input is provided via standard input and the output should be written to standard output.

inputFormat

The first line of input contains a single integer \(T\), the number of test cases. Each test case is described as follows:

  • The first line of each test case contains two space-separated integers \(n\) and \(k\), where \(n\) is the number of elements in the array and \(k\) indicates that you should find the kth smallest element.
  • The second line contains \(n\) space-separated integers representing the array elements.

You must process all test cases from standard input.

outputFormat

For each test case, output a single line containing the kth smallest element in the array.

## sample
5
6 3
7 10 4 3 20 15
5 2
7 10 4 20 15
3 1
9 1 5
4 4
2 2 1 1
10 5
10 9 8 7 6 5 4 3 2 1
7

7 1 2 5

</p>