#include #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; int main() { int n; string s; cin >> n >> s; int m = round(sqrt(n)); cout << (s == string(n, 'Q') and m * m == n ? string(m, 'Q') : "-1") << endl; return 0; }