def generate_99_song(): song = [] for i in range(99, 0, -1): line1 = f"{i} bottles of beer on the wall, {i} bottles of beer.\n" song.append(line1) line2 = "Take one down and pass it around, " if i == 1: line2 += "no more bottles of beer on the wall.\n\n" else: line2 += f"{i-1} bottles of beer on the wall.\n\n" song.append(line2) return ''.join(song) hello = "Hello, World!" song = generate_99_song() def is_hq9_plus_without_q(s, hello_str, song_str): index = 0 code = [] hello_len = len(hello_str) song_len = len(song_str) while index < len(s): if s.startswith(hello_str, index): code.append('H') index += hello_len elif song_len > 0 and s.startswith(song_str, index): code.append('9') index += song_len else: return None return ''.join(code) if index == len(s) else None n = int(input()) s = input().strip() if s == hello: print("H") elif s == song: print("9") else: q_count = s.count('Q') h_count = s.count('H') nine_count = s.count('9') if q_count == 1 and h_count == 0 and nine_count == 0: print(s) else: code = is_hq9_plus_without_q(s, hello, song) if code is not None: print(code) else: print(-1)