human
Write me a Python program to print one integer — the minimum possible number of kicks in the penalty phase given the following:
PYTHON3 solution for "Consider a simplified penalty phase at the end of a football match.

A penalty phase consists of at most 10 kicks, the first team takes the first kick, the second team takes the second kick, then the first team takes the third kick, and so on. The team that scores more goals wins.
if both teams score the same number of goals, the game results in a tie (note that it goes against the usual football rules). The penalty phase is stopped if one team has scored more goals than the other team could reach with all of its remaining kicks. For example, if after the 7-th kick the first team has scored 1 goal, and the second team has scored 3 goals, the penalty phase ends — the first team cannot reach 3 goals.

You know which player will be taking each kick, so you have your predictions for each of the 10 kicks. These predictions are represented by a string s consisting of 10 characters. Each character can either be 1, 0, or ?. This string represents your predictions in the following way:

  * if s_i is 1, then the i-th kick will definitely score a goal.

  * if s_i is 0, then the i-th kick definitely won't score a goal.

  * if s_i is ?, then the i-th kick could go either way. 


Based on your predictions, you have to calculate the minimum possible number of kicks there can be in the penalty phase (that means, the earliest moment when the penalty phase is stopped, considering all possible ways it could go). Note that the referee doesn't take into account any predictions when deciding to stop the penalty phase — you may know that some kick will/won't be scored, but the referee doesn't.

Input

The first line contains one integer t (1 ≤ t ≤ 1 000) — the number of test cases.

Each test case is represented by one line containing the string s, consisting of exactly 10 characters. Each character is either 1, 0, or ?.

Output

For each test case, print one integer — the minimum possible number of kicks in the penalty phase.

Example

Input

4
1?0???1001
1111111111
??????????
0100000000

Output

7
10
6
9

Note

Consider...":
assistant
#Here is Python program to print one integer — the minimum possible number of kicks in the penalty phase.
 def minPossibleKicks(predictions):
    n = len(predictions)
    d = n

    scores = [0, 0]
    for turn in range(n):
        if turn % 2 == 0:
            scores[0] += (predictions[turn] == '1')
        else:
            scores[1] += (predictions[turn] != '0')
        if scores[0] > scores[1] + (10 - turn) // 2:
            d = min(d, turn)
        if scores[1] > scores[0] + (9 - turn) // 2:
            d = min(d, turn)

    scores = [0, 0]
    for turn in range(n):
        if turn % 2 != 0:
            scores[1] += (predictions[turn] == '1')
        else:
            scores[0] += (predictions[turn] != '0')
        if scores[0] > scores[1] + (10 - turn) // 2:
            d = min(d, turn)
        if scores[1] > scores[0] + (9 - turn) // 2:
            d = min(d, turn)

    return min(n, d + 1)

if __name__ == "__main__":
    t = int(input())
    for case in range(t):
        s = input()
        print(minPossibleKicks(s))