#include <iostream>
#include <vector>
using namespace std;
int n;
int z[255];
bool vw(char c){
return c=='a' || c=='e' || c=='i' || c=='o' || c=='u' || c=='y';
}
bool ien(string s){
if (!vw(s[0]) && !vw(s[1])) return 1;
if (!vw(s[s.size()-1])) return 1;
for (int i='a'; i<='z'; ++i) z[i]=0;
for (int i=0; i<s.size(); ++i){
if (i && s[i]==s[i-1]) return 0;
++z[s[i]];
}
if (z['b'] || z['c'] || z['d'] || z['f'] || z['g'] || z['q'] || z['w'] || z['x'] || z['z']) return 1;
if (z['y'] && (z['a'] || z['o'] || z['u'])) return 1;
char kv=s[s.size()-3];
if (s[s.size()-1]=='e' && (kv=='u' || kv=='i')) return 1;
return 0;
}
int main(){
cin >> n;
for (int i=0; i<n; ++i){
string s;
cin >> s;
if (ien(s)) cout << "QAQ\n";
else cout << "10-4\n";
}
}