#include #include using namespace std; int main(){ int i,n; cin >> n; string s; cin >> s; if(s.back()!='Q') cout << -1 << endl; else{ s.pop_back(); cout << s; cout << "Q" << endl; } }