Guess the number

Alfredo and Beatriz are playing the well known game “Guess the number”. Alfredo has thought a number between 1 and 500, and Beatriz has 10 attempts to guess it. For each attempt of Beatriz, Alfredo has to answer “greater” (if Beatriz said a number less than the one that Alfredo thought) or “less” (if the said number was greater).

Your task in this problem is the following one: assuming that Beatriz has already done 9 attempts, none of them has been succesful, you must find out if these attempts are enough to find out the number thought by Alfredo (and, therefore, Beatriz will guess in the tenth attempt if she says that number) or if, otherwise, it could be many possible answers.

Input

The input contains in a line the number nn of cases. nn lines follow, each one of them describes a case. A case is formed by 9 pairs gag\ a, separated by spaces, where gg is a number between 11 and 500500 proposed by Beatriz and aa is the answer that Alfredo gave: the signal ‘+’ indicates that the answer of Alfredo is “Greater”, while the signal ‘-’ indicates “Less”.

Alfredo never lies nor is wrong in his answers.

Output

The output consists of nn lines, each one of them gives the solution of a case. Your program must print the number in a line if you can certainly know the number thought by Alfredo. Otherwise, it must print ‘?’ in a line (Follow the format of the instances).

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T11:30:59.114Z

© Jutge.org, 2006–2026.
https://jutge.org