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 the example test:

In the first test case, consider the situation when the 1-st, 5-th and 7-th kicks score goals, and kicks 2, 3, 4 and 6 are unsuccessful. Then the current number of goals for the first team is 3, for the second team is 0, and the referee sees that the second team can score at most 2 goals in the remaining kicks. So the penalty phase can be stopped after the 7-th kick.

In the second test case, the penalty phase won't be stopped until all 10 kicks are finished.

In the third test case, if the first team doesn't score any of its three first kicks and the second team scores all of its three first kicks, then after the 6-th kick, the first team has scored 0 goals and the second team has scored 3 goals, and the referee sees that the first team can score at most 2 goals in the remaining kicks. So, the penalty phase can be stopped after the 6-th kick.

In the fourth test case, even though you can predict the whole penalty phase, the referee understands that the phase should be ended only after the 9-th kick.

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;



import static javax.swing.UIManager.get;
import static javax.swing.UIManager.getString;


public class Main {


    static class Pair implements Comparable<Pair> {
        int x = 0;
        int y = 0;

        public Pair(int x1, int y1) {
            x = x1;
            y = y1;
        }


        @Override
        public int compareTo(Pair o) {
            return this.x - o.x;
        }
    }

    static boolean checkPallindrome(int n) {
        ArrayList<Integer> list = new ArrayList<>();
        while (n > 0) {
            list.add(n % 10);
            n /= 10;
        }
        int low = 0, high = list.size() - 1;
        while (low <= high) {
            if (list.get(low) != list.get(high))
                return false;
            low++;
            high--;
        }
        return true;
    }


    static boolean check(String s) {

        int low = 0, high = s.length() - 1;
        while (low <= high) {
            if (s.charAt(low) != s.charAt(high))
                return false;
            low++;
            high--;
        }
        return true;
    }

    class Node implements Comparable<Node> {
        int x = 0, y = 0, z = 0;

        @Override
        public int compareTo(Node o) {
            return this.y - o.y;
        }
    }

    static int min = Integer.MAX_VALUE;

    public static void main(String[] args) throws IOException {
        FastReader sc = new FastReader();
//(1)very very important**(never take the first problem for granted, always check the test cases) take 5 minutes more and check the edge cases
        // 5 minutes will not decreases rating as much as a wrong submission does it is easy u just think with an open mind and u will surely get the answer
        //(2)let ur brain consume the problem don't just jump to the solution. after reading the problem take a pause 1 minute
        //(3)go through the example test cases and also at least two of ur own test cases.Think of testcases which are difficult(edge cases).dry run ur concept

        int t = sc.nextInt();
        while (t-- > 0) {
      String s = sc.nextLine();
      int i=0,count1=0,counter1=0,count2=0,counter2=0,x=0,ans=0;

      for(i=0;i<10;i++)
      {
          if(i%2==0)
          {  if(s.charAt(i)=='1')
              count1++;
              else if(s.charAt(i)=='?')
                  counter1++;
          }
          else
          {
              if(s.charAt(i)=='1')
                  count2++;
              else if(s.charAt(i)=='?')
                  counter2++;
          }


          if(count1+counter1>count2)
          {
              if((10-(i+1))%2==0)
              x=(10-(i+1))/2;
              else
                  x=((10-(i+1))/2)+1;
              if(count1+counter1>count2+x)
              { ans=i+1;
                  break;
              }
          }
          if(count2+counter2>count1)
          {


              if((10-(i+1))%2==0)
                  x=(10-(i+1))/2;
              else
                  x=(10-(i+1))/2;
              if(count2+counter2>count1+x)
              { ans=i+1;
                  break;
              }
          }
      }
if(i==10)
    System.out.println(i);
     else  System.out.println(ans);

    }
}











    static class DisjointUnionSets {
        int[] rank, parent;
        int n;

        // Constructor
        public DisjointUnionSets(int n)
        {
            rank = new int[n];
            parent = new int[n];
            this.n = n;
            makeSet();
        }

        // Creates n sets with single item in each
        void makeSet()
        {
            for (int i = 0; i < n; i++) {
                // Initially, all elements are in
                // their own set.
                parent[i] = i;
            }
        }

        // Returns representative of x's set
        int find(int x)
        {
            // Finds the representative of the set
            // that x is an element of
            if (parent[x] != x) {
                // if x is not the parent of itself
                // Then x is not the representative of
                // his set,
                parent[x] = find(parent[x]);

                // so we recursively call Find on its parent
                // and move i's node directly under the
                // representative of this set
            }

            return parent[x];
        }

        // Unites the set that includes x and the set
        // that includes x
        void union(int x, int y)
        {
            // Find representatives of two sets
            int xRoot = find(x), yRoot = find(y);

            // Elements are in the same set, no need
            // to unite anything.
            if (xRoot == yRoot)
                return;

            // If x's rank is less than y's rank
            if (rank[xRoot] < rank[yRoot])

                // Then move x under y  so that depth
                // of tree remains less
                parent[xRoot] = yRoot;

                // Else if y's rank is less than x's rank
            else if (rank[yRoot] < rank[xRoot])

                // Then move y under x so that depth of
                // tree remains less
                parent[yRoot] = xRoot;

            else // if ranks are the same
            {
                // Then move y under x (doesn't matter
                // which one goes where)
                parent[yRoot] = xRoot;

                // And increment the result tree's
                // rank by 1
                rank[xRoot] = rank[xRoot] + 1;
            }
        }
    }














// syntax of conditional operator y=(x==1)?1:0;
//Things to check when u r getting wrong answer
// 1-  check the flow of the code
//2- If ur stuck read the problem once again
//3- before submitting always check the output format of ur code
//4- don't check standings until problem B is done
//5- if u r thinking ur concept is correct but still u r getting wrong answer try to implement it in another way
//6- By default, java interpret all numeral literals as 32-bit integer values.
// If you want to explicitely specify that this is something bigger then 32-bit integer you should use suffix L for long values.    example   long a = 600851475143L

//All the functions



    static void debug(String s)
    { System.out.println(s);

    }

    //collections.sort use merge sort instead of quick sort but arrays.sort use quicksort whose worst time complexity is O(n^2)
    static int[] sort(int[] a)
    {         ArrayList<Integer> list = new ArrayList<>();
        for(int i=0;i<a.length;i++)
            list.add(a[i]);

        Collections.sort(list);
        int ind=0;
        for(int x:list)
            a[ind++]=x;
        return a;

    }

    //function to print an array for debugging
    static void print(int[] a) {
        for (int i = 0; i < a.length; i++)
            System.out.print(a[i] + " ");
        System.out.println();
    }

    static void printc(char[] a) {
        for (int i = 0; i < a.length; i++)
            System.out.print(a[i] + " ");
        System.out.println();
    }


    //normal gcd function, always put the greater number as a and the smaller number as b
    static int gcd(int a, int b) {
        if (b == 0)
            return a;
        return gcd(b, a % b);

    }

    static int lcm(int a,int b)
    {
        return (a*b)/gcd(a,b);
    }


    //to find gcd and lcm for numbers of long data type
    static long gcdl(long a, long b) {
        if (b == 0)
            return a;
        return gcdl(b, a % b);

    }

    static long lcml(long a,long b)
    {
        return (a*b)/gcdl(a,b);
    }


    //Input Reader to read faster input
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


        int[] readArray(int n)
        {  int[] a = new int[n];
            for(int i=0;i<n;i++)
                a[i]=nextInt();

            return a;
        }
    }



}

































































