#include <bits/stdc++.h>
using namespace std;
long long int binExp(long long int x, long long int n, long long int m) {
  long long int res = 1;
  while (n) {
    if (n & 1) res = (res * x) % m;
    x = (x * x) % m;
    n >>= 1;
  }
  return res;
}
long long int modInv(long long int i, long long int m) {
  return binExp(i, m - 2, m);
}
long long int add(long long int a, long long int b) {
  long long int res = a + b;
  if (res >= 1000000007) res -= 1000000007;
  if (res < 0) res += 1000000007;
  return res;
}
long long int mul(long long int a, long long int b) {
  long long int res = (a) * (b);
  res %= 1000000007;
  if (res < 0) res += 1000000007;
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t, t1 = 1;
  cin >> t;
  while (t--) {
    string str;
    cin >> str;
    int odd = 0, even = 0, oddq = 0, evenq = 0, oddt = 0, event = 0, ans = 0;
    for (int i = 0; i < 10; i++) {
      if (i % 2 != 0) {
        event++;
        if (str[i] == '1') {
          even++;
        }
        if (str[i] == '?') {
          evenq++;
        }
        int oddrem = 5 - oddt;
        int evenrem = 5 - event;
        if ((odd + oddq - even) > evenrem) {
          ans = i + 1;
          break;
        }
        if ((even + evenq - odd) > oddrem) {
          ans = i + 1;
          break;
        }
      } else {
        oddt++;
        if (str[i] == '1') {
          odd++;
        }
        if (str[i] == '?') {
          oddq++;
        }
        int oddrem = 5 - oddt;
        int evenrem = 5 - event;
        if ((odd + oddq - even) > evenrem) {
          ans = i + 1;
          break;
        }
        if ((even + evenq - odd) > oddrem) {
          ans = i + 1;
          break;
        }
      }
    }
    if (ans == 0) {
      cout << 10 << endl;
      continue;
    }
    cout << ans << endl;
  }
  return 0;
}
