Given an input stream of **n** integers, find the k^{th} largest element for each element in the stream.

**Input:**

The first line of input contains an integer **T** denoting the number of test cases. Then T test cases follow. Each test case contains two lines. The first line of each test case contains two space separated integers **k** and **n** . Then in the next line are **n** space separated values of the array.

**Output:**

For each test case, in a new line, print the space separated values denoting the **k ^{th}** largest element at each insertion, if the

**Constraints:**

1<=T<=100

1<=n,k<=10^{3}

1<=stream[]<=10^{5}

**Example:
Input:**

2

4 6

1 2 3 4 5 6

1 2

3 4

-1 -1 -1 1 2 3

3 4

**Explanation:
Testcase1:**

k = 4

For 1, the 4th largest element doesn't exist so we print -1.

For 2, the 4th largest element doesn't exist so we print -1.

For 3, the 4th largest element doesn't exist so we print -1.

For 4, the 4th largest element is 1 {1, 2, 3, 4}

For 5, the 4th largest element is 2 {2, 3, 4 ,5}

for 6, the 4th largest element is 3 {3, 4, 5}

Timer is Running

Average Time : 30 minutes

blackshadows | 210 |

xmyqsh | 198 |

hanuman001 | 164 |

Adarsh Trivedi | 148 |

layman_brother | 144 |

blackshadows | 692 |

xmyqsh | 539 |

aman19 | 398 |

r0c2048 | 360 |

kspk | 331 |

akhayrutdinov | 5005 |

Ibrahim Nash | 4871 |

Quandray | 4338 |

sanjay05 | 3668 |

blackshadows | 3196 |

Login to report an issue on this page.