#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using pii = pair <int, int>;
using pll = pair <ll, ll>;

#define FIO() ios_base::sync_with_stdio(0);cin.tie(NULL);

const ll inf = 9e18;

int main() {
    FIO();

    string atc = "atcoder";

    int tc; cin >> tc;
    while (tc--) {
        string s; cin >> s;
        ll ans = inf;
        ll temp = 0;

        int m = min(atc.size(), s.size());
        int n = s.size();

        bool ok = true;
        for (int i = 0; i < m; i++) {
            if (s[i] > atc[i]) {
                ans = min(ans, temp);
                break;
            }

            for (int j = i + 1; j < n; j++) {
                if (s[j] > atc[i]) {
                    ans = min(ans, temp + j - i);
                    break;
                }
            }

            bool fnd = false;
            for (int j = i; j < n; j++) {
                if (s[j] != atc[i]) continue;

                fnd = true;
                while (s[i] != atc[i]) {
                    swap(s[j], s[j - 1]);
                    j--;
                    temp++;
                }

                break;
            }

            if (!fnd) {
                ok = false;
                break;
            }
        }

        if (ok and m < s.size()) ans = min(ans, temp);

        if (ans == inf) ans = -1;
        cout << ans << '\n';
    }
}

#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef DEBBY
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
      *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define ll long long
#define print_mat(i,j,a,b,v) for(int i=0;i<a;i++){for(int j=0;j<b;j++)cerr<<v[i][j] << " "; cerr<<endl;}
#define sz(v)  (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pi pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vpi vector<pi>
#define pq priority_queue<int>
#define pqg priority_queue<int, vi, greater<int> >
#define fs first
#define sd second
#define pb push_back
#define eb emplace_back

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
///////////////////////////////////////
// READING
template<class A> void read(vector<A>& v);
template<class A, size_t S> void read(array<A, S>& a);
template<class T> void read(T& x) {
	cin >> x;
}
void read(double& d) {
	string t;
	read(t);
	d=stod(t);
}
void read(long double& d) {
	string t;
	read(t);
	d=stold(t);
}
template<class H, class... T> void read(H& h, T&... t) {
	read(h);
	read(t...);
}
template<class A> void read(vector<A>& x) {
	EACH(a, x)
		read(a);
}
template<class A, size_t S> void read(array<A, S>& x) {
	EACH(a, x)
		read(a);
}
////////////////////////////////
// PRINTING
string to_string(char c) {
	return string(1, c);
}
string to_string(bool b) {
	return b?"true":"false";
}
string to_string(const char* s) {
	return string(s);
}
string to_string(string s) {
	return s;
}
string to_string(vector<bool> v) {
	string res;
	FOR(sz(v))
		res+=char('0'+v[i]);
	return res;
}

template<size_t S> string to_string(bitset<S> b) {
	string res;
	FOR(S)
		res+=char('0'+b[i]);
	return res;
}
template<class T> string to_string(T v) {
    bool f=1;
    string res;
    EACH(x, v) {
		if(!f)
			res+=' ';
		f=0;
		res+=to_string(x);
	}
    return res;
}

template<class A> void write(A x) {
	cout << to_string(x);
}
template<class H, class... T> void write(const H& h, const T&... t) { 
	write(h);
	write(t...);
}
void print() {
	write("\n");
}
template<class H, class... T> void print(const H& h, const T&... t) { 
	write(h);
	if(sizeof...(t))
		write(' ');
	print(t...);
}
////////////////////////////////
// START PROGRAM
///////////////////////////////

void solve(){
    int n;
    read(n); 
    
    if(n & 1)
      print("Black"); 
    else
      print("White");
            
} 

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    solve();
    
    return 0;
}
    



