Roy and Alfi reside in two different cities, Roy in city A and Alfi in city B. Roy wishes to meet her in city B.
There are two trains available from city A to city B. Roy is on his way to station A (Railway station of city A). It will take
If its not possible to reach city B, print "-1" instead (without quotes).
Note: If the minimum time is not integral, round the value to the least integer greater than minimum time.
Input:
First line will contain integer T, number of test cases.
Second line will contain integers **
Output:
Print the integral result, minimum time (in minutes) to reach city B in a new line.
Constraints:
1 5 5 8 100 90 320
197
Roy reaches station A in 5 minutes, First train departs in 5 minutes and second train departs in 8 minutes, he will be able to catch both of them. But he has to make an optimal choice, which train reaches city B in minimum time. For first train
For second train
Please login to use the editor
You need to be logged in to access the code editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor