CodeMart is an online shopping platform and it is distributing gift vouchers to its esteemed users. The voucher can be redeemed by providing a fixed amount of shopping credits.Each credit is sent by a user one by one. Since there is a huge rush of people you are required to manage the users on the basis of first come first serve. The user which comes first and has k occurrences of credits is given the voucher first. You are given an array with the id's of the users in chronological order of the credits sent by them. You are required to print the id of the user which will be served first. If no such user meets the condition print "-1".
The first line of input contains an integer T denoting the number of test cases. Each test case contains two integers n and k where n denoted the number of elements in the array a. Next line contains space separated n elements in the array a.
Output a single integer which is the number of first k occurrences. Output "-1" if no such number exists.
1 7 4 3 4 8 7
4 1 6 1 6 4
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?Yes