#include using namespace std; int main() { int n; string s; cin >> n >> s; int count = 0; for (int i = 0; i < n; i++) { if (s[i] == 'Q') count++; if (s[i] == 'H') { cout << -1 << '\n'; return 0; } } if (sqrt(count) * sqrt(count) != count) { cout << -1 << '\n'; return 0; } string t = ""; for (int i = 0; i < n / sqrt(count); i++) t += s[i]; string t2 = ""; for (int i = 0; i < sqrt(count); i++) t2 += t; if (t2 != s) cout << -1 << '\n'; else cout << t << '\n'; }