input() S = input() if 'Q' not in S: S = -1 print(S)