#include <bits/stdc++.h>
using namespace std;
void printVec(vector<int> f){
for(int i=0;i<f.size();i++){
cout << f[i];
}
cout << endl;
}
int main() {
int t,n;
cin >> t;
while(t--){
cin >> n;
if(n%2 == 0) cout << "0\n";
else{
int t = n, c = 0;
vector<int> temp;
while(t>0){
temp.push_back(t % 10);
t /= 10;
}
vector<int> a;
for(int i=temp.size()-1;i >= 0;--i){
a.push_back(temp[i]);
}
// printVec(temp);
// printVec(a);
bool even = false;
for(int i=0;i<a.size();i++){
if(a[i] % 2 == 0){
cout << min(2,i+1) << endl;
even = true;
break;
}
}
if(!even) cout << "-1\n";
}
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgp2b2lkIHByaW50VmVjKHZlY3RvcjxpbnQ+IGYpewoJZm9yKGludCBpPTA7aTxmLnNpemUoKTtpKyspewoJCWNvdXQgPDwgZltpXTsKCX0KCWNvdXQgPDwgZW5kbDsKfQoKaW50IG1haW4oKSB7CglpbnQgdCxuOwoJY2luID4+IHQ7Cgl3aGlsZSh0LS0pewoJCWNpbiA+PiBuOwoJCWlmKG4lMiA9PSAwKQljb3V0IDw8ICIwXG4iOwoJCWVsc2V7CgkJCWludCB0ID0gbiwgYyA9IDA7CgkJCXZlY3RvcjxpbnQ+IHRlbXA7CgkJCXdoaWxlKHQ+MCl7CgkJCQl0ZW1wLnB1c2hfYmFjayh0ICUgMTApOwoJCQkJdCAvPSAxMDsKCQkJfQoJCQl2ZWN0b3I8aW50PiBhOwoJCQlmb3IoaW50IGk9dGVtcC5zaXplKCktMTtpID49IDA7LS1pKXsKCQkJCWEucHVzaF9iYWNrKHRlbXBbaV0pOwoJCQl9CgkJCS8vIHByaW50VmVjKHRlbXApOwoJCQkvLyBwcmludFZlYyhhKTsKCQkJYm9vbCBldmVuID0gZmFsc2U7CgkJCWZvcihpbnQgaT0wO2k8YS5zaXplKCk7aSsrKXsKCQkJCWlmKGFbaV0gJSAyID09IDApewoJCQkJCWNvdXQgPDwgbWluKDIsaSsxKSA8PCBlbmRsOwoJCQkJCWV2ZW4gPSB0cnVlOwoJCQkJCWJyZWFrOwoJCQkJfQkKCQkJfQoJCQlpZighZXZlbikJY291dCA8PCAiLTFcbiI7CgkJfQoJfQoJcmV0dXJuIDA7Cn0=