Go Back
Jumping Rahul (0)
Description

Rahul is playing a VR game. He is stuck in a mission and needs your help.
In this mission, Rahul is stranded on a rock and needs to jump through a series of rock to save himself from falling into a death vortex. You are given T scenarios and at each scenario you have to tell whether Rahul will be able to jump on any of the rocks around him or not.

Now the problem is, Rahul can only jump on rock which can handle the weight greater than his weight. Luckily you know all the information, help Rahul by telling to jump on which rock.

Input

First line of input contains T - the number of test cases. Next T lines contains 5 spaced integers.
First integer represents the weight of Rahul and the rest 4 integers represent the weight a rock can handle which is around him.

Output

Print the weight of rock with maximum weight which will handle Rahul's weight. If there is no such rock print -1.

Constraints

1 <= T <= 50
1 <= N, W[i] <= 1000

Example
Copy Input

Input:
3
4 2 3 1 5
4 2 8 1 4
4 2 3 1 4
Output:
5
8
-1

Explanation

No explanation available

Universe
Contest open for 1 year with playlists problems



Announcement


Supported by our Coding Partner