#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    string k = "#" + s;
    long long ans = 10;
    long long n = s.length();
    for (long long i = 1; i <= n; i++) {
      long long goala = 0;
      long long goalb = 0;
      long long rema = 0;
      long long remb = 0;
      long long goalaa = 0;
      long long goalbb = 0;
      for (int j = 1; j <= i; j++) {
        if (j % 2) {
          if (k[j] == '1' || k[j] == '?') {
            goala++;
          }
          if (k[j] == '1') {
            goalaa++;
          }
        } else {
          if (k[j] == '1') {
            goalb++;
          }
          if (k[j] == '1' || k[j] == '?') {
            goalbb++;
          }
        }
      }
      for (int j = i + 1; j <= n; j++) {
        if (j % 2) {
          rema++;
        } else {
          remb++;
        }
      }
      if (goala > remb + goalb) {
        ans = i;
        break;
      } else if (goalbb > rema + goalaa) {
        ans = i;
        break;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
