There are a lot of people on the Tg. Mureș stock market. Some buy shares, others sell. Transactions are recorded electronically at Smart Software Company, where program¬mers are prepared to answer various questions. This morning, the business manager asked something from Rookie, a recently hired programmer, but he could not answer. If you succeed to answer the question, the manager will give you an award and – who knows – he might even hire you at the Smart Software Company.
Manager's question: What is the value of the transaction which is larger (or equal) than k – 1 other transactions?
The first line of the input contains the number of test cases t. The first line of each test case includes the number n (the total number of transactions in the Smart database) and the number k (with the meaning given in the requirement). Each of the following n lines contains an integer (positive numbers are incomes for the market, negative numbers represent payments). Two test cases are separated by an empty line.
For each test case, your program has to print on a separate line the value of the traded amount, that is, the kth smallest value in the Smart database.
Restrictions and Refinements
Output for Sample Input
Explanation of Sample Input
The numbers in ascending order:
|University of Debrecen; Faculty of Informatics; v. 03/01/2019|