#include using namespace std; int main() { int N; string S; cin >> N >> S; if(S[N-1] == 'Q') { cout << S.substr(0,N-1) << 'Q' << endl; } else { cout << -1 << endl; } }