Find My Candy

0

0 votes
Problem

You are given candies of different sizes and their respective count.

Each student is given a single candy one by one in non-decreasing order of size of candy.Given the position P of a student find the size of the candy he will receive. 

Print -1 if the student does not receive any candy.

Constraints

1<=T<=10

1≤N≤10^5

1≤a_i,b_i≤10^9

1≤P≤10^14

All input values are integers.

Input 

The input is given in the following manner

First line contains the integer T i.e the no of test cases.

The next t lines contain the following values ->

First line contains two integrs N and P.

The next line contains n integers i.e the  sizes of candies.

The last line contains n integes i.e the corresponding count of candies. 

Output

For each test case return the size of the candy the student at position P will receive or -1 if he does not get any candy.

Time Limit: 5
Memory Limit: 256
Source Limit:
Editor Image

?