#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef long double ld;
int lol[300];
// VOI LOL MIKÄ TEHTÄVÄ
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
lol['a']=14;
lol['b']=-500;
lol['c']=-500;
lol['d']=-500;
lol['e']=-14;
lol['f']=-500;
lol['g']=-500;
lol['h']=0;
lol['i']=8;
lol['j']=500;
lol['k']=0;
lol['l']=0;
lol['m']=0;
lol['n']=0;
lol['o']=2;
lol['p']=0;
lol['q']=-500;
lol['r']=0;
lol['s']=0;
lol['t']=0;
lol['u']=12;
lol['v']=0;
lol['w']=-500;
lol['x']=-500;
lol['y']=-4;
lol['z']=-500;
int su=0;
for (int i=0;i<300;i++){
if (lol[i]!=-500&&lol[i]!=500){
su+=lol[i];
}
}
srand(time(0));
//cout<<su<<endl;
int n;
cin>>n;
for (int i=0;i<n;i++){
string s;
cin>>s;
int t=0;
for (char c:s){
t+=lol[c];
}
if (t==0){
if (rand()%100<60){
cout<<"10-4\n";
}
else{
cout<<"QAQ\n";
}
}
else if (t>0){
cout<<"10-4\n";
}
else{
cout<<"QAQ\n";
}
}
}