#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#define ll long long
#define N (2<<16)
using namespace std;
#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 fi = 0, en = 0;
for (int x = 0; x < s.length() - 2; x++) if (s.substr(x, 2) == "aa") fi += 0.8;
for (int x = 0; x < s.length() - 2; x++) if (s.substr(x, 2) == "ia") fi += 1.2;
for (int x = 0; x < s.length() - 2; x++) if (s.substr(x, 2) == "da") fi += 0.7;
for (int x = 0; x < s.length() - 2; x++) if (s.substr(x, 2) == "ta") fi += 0.2;
for (int x = 0; x < s.length() - 2; x++) if (s.substr(x, 2) == "ss") fi += 0.3;
for (int x = 0; x < s.length() - 2; x++) if (s.substr(x, 2) == "da") fi += 0.7;
for (int x = 0; x < s.length() - 2; x++) if (s.substr(x, 2) == "er") fi += 0.9;
for (int x = 0; x < s.length() - 3; x++) if (s.substr(x, 3) == "ul") fi += 1.5;
for (int x = 0; x < s.length() - 3; x++) if (s.substr(x, 3) == "oh") fi += 1.5;
for (int x = 0; x < s.length() - 3; x++) if (s.substr(x, 3) == "si") fi += 0.8;
//for (int x = 0; x < s.length() - 2; x++) if (s.substr(x, 2) == "er") fi += 0.9;
for (int x = 0; x < s.length() - 1; x++) if (s.substr(x, 1) == "c") en += 0.9;
for (int x = 0; x < s.length() - 1; x++) if (s.substr(x, 1) == "z") en += 1.3;
for (int x = 0; x < s.length() - 1; x++) if (s.substr(x, 1) == "x") en += 1.3;
for (int x = 0; x < s.length() - 1; x++) if (s.substr(x, 1) == "w") en += 1.5;
for (int x = 0; x < s.length() - 2; x++) if (s.substr(x, 2) == "nd") en += 1.2;
for (int x = 0; x < s.length() - 3; x++) if (s.substr(x, 3) == "ing") en += 1.5;
if (fi >= en) {
cout<<"10-4"<<endl;
} else {
cout<<"QAQ"<<endl;
}
}
}