#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

typedef pair<int,int>  pint;
typedef pair<ll,ll>    pll;
typedef vector<int>    vint;
typedef vector<ll>     vll;
typedef vector<string> vstr;
typedef vector<pint>   vpint;
typedef vector<pll>    vpll;

#define vint2(v,n,m,init) vector<vector<int>> v(n, vector<int>(m, init))
#define vll2(v,n,m,init)  vector<vector<ll>>  v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vint var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vstr var(n); rep(i,n){cin >> var[i];}
#define ALL(var)         (var).begin(), (var).end()
#define sortall(var)     sort(ALL(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());

#define prt(var)         cout << (var) << "\n"
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
template <typename T>
bool chmax(T &a, const T& b){if(a<b){a=b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a>b){a=b; return true;} return false;}
ll gcd(ll a, ll b){ return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){ return a/gcd(a,b)*b;}
//----------------------------------------------------------------------------
#define prt4(v1,v2,v3,v4) cout<<(v1)<<" "<<(v2)<<" "<<(v3)<<" "<<(v4)<<"\n";

int main(void) {
    arrll(a,4);

    ll k = a[0] + a[1] + a[2] + a[3];
    bool ok = false;
    rep(i,4){
        REP(j,i+1,4){
            if(a[i]+a[j]==k-a[i]-a[j]) ok = true;
        }
    }

    rep(i,4){
        if(a[i]==k-a[i]) ok = true;
    }

    prt(ok ? "Yes" : "No");
}

/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

string s,t="atcoder";
int n;

int match(int x){
  if(x==0){
    int res = mod;
    for(int j=0;j<s.size();j++){
      if(s[j]>'a')return j;
    }
    return res;
  }
  int done[n+1]={0};
  int res = 0;
  for(int i=0;i<x;i++){
    int cnt = 0;
    bool f = false;
    for(int j=0;j<s.size();j++){
      if(done[j])continue;
      if(s[j]==t[i]){
        done[j]=1;
        res+=cnt;
        f = true;
        break;
      }
      cnt++;
    }
    if(!f)return mod;
  }
  if(x<t.size()){
    bool f = false;
    int cnt = 0;
    for(int j=0;j<s.size();j++){
      if(done[j])continue;
      if(t[x]<s[j]){
        res+=cnt;
        f = true;
        break;
      }
      cnt++;
    }
    if(!f)return mod;
  }
  else {
    if(s.size()>x)return res;
    else return mod;
  }
  return res;
}

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  int T;
  cin >> T;
  while(T--){
    cin >> s;
    n = s.size();
    int ans = mod;
    for(int i=0;i<=t.size();i++){
      ans = min(ans,match(i));
      // cerr << i << " "  << ans << endl;
    }
    if(ans>=mod){
      ans = -1;
    }
    cout << ans << endl;
  }


return 0;
}
///....
