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