#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#define ll long long
#define N (2<<16)
using namespace std;
int main () {
int n;
cin>>n;
for (int i = 0; i < n; i++) {
string s;
cin>>s;
double v = 0;
for (char c : s) if (c == 'a') v += 0.01;
for (char c : s) if (c == 'b') v += -0.09;
for (char c : s) if (c == 'c') v += -1;
for (char c : s) if (c == 'd') v += -0.018;
for (char c : s) if (c == 'e') v += 0.025;
for (char c : s) if (c == 'f') v += -0.09;
for (char c : s) if (c == 'g') v += -0.09;
for (char c : s) if (c == 'h') v += -0.01;
for (char c : s) if (c == 'i') v += 0.015;
for (char c : s) if (c == 'k') v += 0.02;
for (char c : s) if (c == 'l') v += 0.015;
for (char c : s) if (c == 'm') v += -0.03;
for (char c : s) if (c == 'n') v += 0.03;
for (char c : s) if (c == 'o') v += -0.03;
for (char c : s) if (c == 'p') v += -0.023;
for (char c : s) if (c == 'q') v += -1;
for (char c : s) if (c == 'r') v += -0.021;
for (char c : s) if (c == 's') v += 0.025;
for (char c : s) if (c == 't') v += 0.025;
for (char c : s) if (c == 'u') v += -0.035;
for (char c : s) if (c == 'v') v += 0.02;
for (char c : s) if (c == 'w') v += -1;
for (char c : s) if (c == 'x') v += -1;
for (char c : s) if (c == 'y') v += -0.2;
for (char c : s) if (c == 'z') v += -1;
if (v >= 0) {
cout<<"10-4"<<endl;
} else {
cout<<"QAQ"<<endl;
}
}
}