#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
typedef long long LL;
using namespace std;
string foreign = "zxcbfqw";
string finnish = "10-4";
string english = "QAQ";
bool is_foreign(char c){
for(char f : foreign) if(c == f) return true;
return false;
}
string classify(string& s){
LL nForeign = 0;
for(char c : s){
if(c > 'z') return finnish;
if(is_foreign(c)) nForeign++;
}
if(nForeign >= 2) return english;
return finnish;
}
int main(){
LL n; cin >> n;
for(int i = 0; i < n; i++){
string s; cin >> s;
cout << classify(s) << "\n";
}
}