Given an array of **N** integers. The task is to find the first element that occurs **K** number of times. If no element occurs **K** times the print **-1**.

**Input:**

The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. The first line of each test case contains an integer N denoting the size of an array and the number K. The second line of each test case contains N space separated integers denoting elements of the array A[ ].

**Output:**

For each test case in a new line print the required answer.

**Constraints:**

1 <= T <= 100

1 <= N, K <= 10^{5}

1<= A <= 10^{6}

**Example:**

**Input :**

1

7 2

1 7 4 3 4 8 7

**Output :**

7

**Explanation:**

Both 7 and 4 occur 2 times. But 7 is the first that occurs 2 times.

Author: sujnesh

SushmitaRaj | 61 |

svashish305 | 54 |

Mr_Bean | 49 |

deepaksh0607 | 48 |

MuhammadHasan | 43 |

kinetic | 317 |

yirans | 278 |

kevinyu102589 | 263 |

rutvik29 | 217 |

kyaba-kun | 206 |

akhayrutdinov | 4913 |

Ibrahim Nash | 4431 |

Quandray | 4261 |

sanjay05 | 3668 |

GB11 | 2857 |

Login to report an issue on this page.