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.
// あぁ 今夜 僕の部屋に来ないかい 何もないけど
// あぁ 今夜 僕の部屋に来ないかい あぁ遠い灯よ

// 季節の終わり そして 広がる花びら
// 季節の終わり そして 広がる涙

#define MTC 1
#define FIO 0

// {{{
#ifdef LOCAL
#include "local.h"
#else
#include <bits/stdc++.h>
#define debug(...)
#endif

using namespace std;
using lint = long long; using ld = long double; using str = string; using pi = pair<int, int>; using pl = pair<lint, lint>; using vi = vector<int>; using vl = vector<lint>; using vb = vector<bool>;
using vpi = vector<pi>; using vpl = vector<pl>; using vvi = vector<vi>; using vvl = vector<vl>; using vvpi = vector<vpi>; using vvpl = vector<vpl>;
template <class T, class Cmp = less<T>> using heap = priority_queue<T, vector<T>, Cmp>; template <class T> using minheap = priority_queue<T, vector<T>, greater<T>>;
mt19937_64 Mt(chrono::steady_clock::now().time_since_epoch().count()); mt19937_64 MtFixed(9999);

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define elif else if

#define For(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, l, r) for (int i = l; i >= r; i--)
#define Rep(i, n) for (int i = 0; i < n; i++)
#define Repd(i, n) for (int i = n - 1; i >= 0; i--)
#define Fe(...) for (auto __VA_ARGS__) 
#define ever (;;)

template <class A, class B> istream& operator>>(istream& is, pair<A, B>& p) { return is >> p.first >> p.second; }
template <class A, class B> ostream& operator<<(ostream& os, const pair<A, B>& p) { return os << p.first << ' ' << p.second; }
template <class T> istream& operator>>(istream& is, vector<T>& v) { for (T& x : v) is >> x; return is; } 
template <class T> ostream& operator<<(ostream& os, const vector<T>& v) { if (v.empty()) return os; int sz = v.size(); for (int i = 0; i < sz - 1; ++i) { os << v[i] << ' '; } return os << v[sz - 1]; } 

struct Rdr { bool ok = true; explicit operator bool() { return ok; } template <class T> Rdr& operator, (T& _t_) { ok &= !!(cin >> _t_); return *this; } };
template <char S, char E> struct Wtr { bool ok = true; bool _space_; void wrCh(char c) { if (c) cout << c; } Wtr() : _space_(false) {} ~Wtr() { wrCh(E); } explicit operator bool() { return ok; } template <class T> Wtr& operator, (const T& _t_) { (_space_) ? (wrCh(S)) : (void(_space_ = true)); ok &= !!(cout << _t_); return *this; } };
#define re Rdr(),
#define pr Wtr<'\0', '\0'>(),
#define prln Wtr<'\0', '\n'>(),
#define wr Wtr<' ', ' '>(),
#define wrln Wtr<' ', '\n'>(),
#define nl cout << '\n'

template <class T> bool chmin(T& t, const T& f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T& t, const T& f) { if (t < f) { t = f; return true; } return false; }
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

template <class I> struct __reversed_struct__ { I& v_; explicit __reversed_struct__(I& v) : v_{v} {} typename I::reverse_iterator begin() const { return v_.rbegin(); } typename I::reverse_iterator end() const { return v_.rend(); } };
template <class I> __reversed_struct__<I> rev(I& v) { return __reversed_struct__<I>(v); }

template <class T, class F> T fsttrue(T lo, T hi, F f) { ++hi; assert(lo <= hi); while (lo < hi) { T mid = lo + (hi - lo) / 2; f(mid) ? hi = mid : lo = mid + 1; } return lo; }
template <class T, class F> T lsttrue(T lo, T hi, F f) { --lo; assert(lo <= hi); while (lo < hi) { T mid = lo + (hi - lo + 1) / 2; f(mid) ? lo = mid : hi = mid - 1; } return lo; }
template <class A, class B> int lwb(const vector<A>& v, B x) { return lower_bound(v.begin(), v.end(), x) - v.begin(); }
template <class A, class B> int upb(const vector<A>& v, B x) { return upper_bound(v.begin(), v.end(), x) - v.begin(); }

template <class T> bool gbit(T mask, int b) { return (mask >> b & T(1)); } template <class T> void sbit(T& mask, int b) { mask |= (T(1) << b); }
template <class T> void dbit(T& mask, int b) { mask &= ~(T(1) << b); } template <class T> void fbit(T& mask, int b) { mask ^= (T(1) << b); }
template <class T> T cdiv(T a, T b) { return a / b + ((a ^ b) > 0 && a % b); } int popcnt(lint x) { return __builtin_popcountll(x); } int clz(lint x) { return __builtin_clzll(x); } int lg2(lint x) { return x ? 63 - clz(x) : 0; }

template <class C> int isz(const C& x) { return static_cast<int>(x.size()); }
template <class T> T rng(T a, T b, bool fixed = false) { return uniform_int_distribution<T>(a, b)(fixed ? MtFixed : Mt); }
template <class T> void remdup(vector<T>& v) { sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), end(v)); }
template <class T> bool inside(T a, T b, T c) { return a <= b && b <= c; }
template <class C, class T> bool contains(const C& x, T a) { return x.find(a) != x.end(); }
template <class T> typename vector<T>::iterator maxof(vector<T>& v) { return max_element(v.begin(), v.end()); }
template <class T> typename vector<T>::iterator minof(vector<T>& v) { return min_element(v.begin(), v.end()); }

#if __cplusplus < 201703L
template <class T> T gcd(T a, T b) { while (b) { a %= b; swap(a, b); } return a; }
template <class T> T lcm(T a, T b) { return 1LL * a / gcd(a, b) * b; }
#endif

#if __cplusplus >= 201402L
template <class F> struct __y_combinator_struct__ { F fun_; template <class T> explicit __y_combinator_struct__(T&& fun): fun_(forward<T>(fun)) {} template <class ...Args> decltype(auto) operator()(Args&& ...args) { return fun_(ref(*this), forward<Args>(args)...); } };
template <class F> decltype(auto) yc(F&& fun) { return __y_combinator_struct__<decay_t<F>>(forward<F>(fun)); }
#endif

struct chash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } };
template <class K, class V> using hmap = unordered_map<K, V, chash>;
template <class K> using hset = unordered_set<K, chash>;

// U UR R DR D DL L UL
constexpr pi d8[8] = {{-1, 0}, {-1, 1}, {0, 1}, {1, 1}, {1, 0}, {1, -1}, {0, -1}, {-1, -1}};
constexpr pi d4[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};

void solve(); void init(); void reset();

signed main() {
#if FIO
#ifndef LOCAL
    freopen("C.inp", "r", stdin);
    freopen("C.out", "w", stdout);
#endif
#endif

    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    cout << setprecision(9) << fixed;

    init();

#if MTC == 1
    int ntc; (cin >> ntc).ignore();
    for (int itc = 0; itc < ntc; itc++)
#elif MTC == 2
    for (;;)
#endif
    {
        solve(); reset();
    }

    return 0;
}

constexpr ld eps = 1e-9;
constexpr int inf = 1e9;
constexpr lint linf = 1e18;
// }}}

constexpr int maxn = 3e5 + 5;

void solve() {
    str s; re s;
    int n = isz(s);

    int ans = inf;

    Rep (mask, 1 << n) {
        vi a(2);
        vi rem(2, n / 2);

        Rep (i, n) {
            --rem[i & 1];
            if (s[i] == '1') {
                ++a[i & 1];
            }
            elif (s[i] == '0') {
                ;
            }
            else {
                a[i & 1] += gbit(mask, i);
            }

            if (a[i & 1] >= a[1 - (i & 1)] + rem[1 - (i & 1)]) {
                chmin(ans, i + 1);
            }
            // elif (a[1] >= a[0] + rem[0]) {
            //     chmin(ans, i + 1);
            // }

            // 0 will win
            // if a[0] >= a[1] + remaining
        }
    }

    wrln ans + 1;
}

void init() {

}

void reset() {

}

// vim: fdm=marker foldenable foldlevel=0
