#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const long long INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
const long long N = 1e3 + 5;
long long t;
string s;
signed main() {
  cin >> t;
  while (t--) {
    long long x = 0, y = 0, minn = INF;
    cin >> s;
    for (long long i = 0; s[i]; i++) {
      if (!(i & 1)) {
        if (s[i] == '1' || s[i] == '?') x++;
      } else {
        if (s[i] == '1') y++;
      }
      if (x > ((10 - i) >> 1) + y) {
        minn = min(i + 1, minn);
        break;
      }
    }
    x = 0, y = 0;
    for (long long i = 0; s[i]; i++) {
      if (!(i & 1)) {
        if (s[i] == '1') x++;
      } else {
        if (s[i] == '1' || s[i] == '?') y++;
      }
      if (y > ((9 - i) >> 1) + x) {
        minn = min(i + 1, minn);
        break;
      }
    }
    if (minn == INF)
      puts("10");
    else
      cout << minn << endl;
  }
}
