#include #include using namespace std; int main() { int N; string S; cin >> N >> S; int B = int(sqrt(N)); if(S == string(B * B, 'Q')) { cout << string(B, 'Q') << endl; } else { cout << -1 << endl; } return 0; }