n = input() s = input() if s[-1] == 'Q' and 'Q' not in s[0 : -1] and 'H' not in s[0 : -1]: print(s) else: print(-1)