/* Ahmed Maher ( Acro_14 )*/
/*while(WA)try();*/
#include <bits/stdc++.h>
using namespace std;

#define fastIO ios::sync_with_stdio(0), ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

typedef long long         ll;
typedef long double   	  ld;

typedef vector<int>       vi;
typedef vector<double>    vd;
typedef vector< vi >      vvi;
typedef vector< vd >      vvd;
typedef vector<string>    vs;


const ll OO = 0x3f3f3f3f;
int const N = 1e5+5;
int const mod = 1e9+7;

/*string Alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet="abcdefghijklmnopqrstuvwxyz";*/

void solve(){
string s,a="atcoder";
cin>>s;
int f=-1;
for(int i=0;i<s.size();i++){
    if(s[i]!='a'){
        f=i;
        break;
    }
}
if(f==-1){
    cout<<f<<endl;
}
else{
    if(s>a) f=0;
    if(s[f]>'t') f--;
    cout<<max(f,0)<<endl;
}
}
int main(){
    /*read
    write*/
    fastIO
    ll t ;
    cin>>t;
    while(t--){
         solve();
    }
    return 0;

}

//       int anss[t+1];
//            anss[j]=ans;
//     for(int j=1;j<=t;j++) printf("Case %d: %d\n",j,anss[j]);

#include<bits/stdc++.h>
using namespace std;
int main() {
  char a, b, c;
  cin >> a >> b >> c;
  cout << (a == b && b == c ? "Won\n" : "Lost\n");
  return 0;
}