def generate_99_bottles(): s = [] for i in range(99, 0, -1): line1 = f"{i} bottle{'s' if i != 1 else ''} of beer on the wall, {i} bottle{'s' if i != 1 else ''} of beer." line2 = f"Take one down and pass it around, {i-1} bottle{'s' if (i-1) != 1 else ''} of beer on the wall." s.append(line1) s.append(line2) s.append("") s.append("No more bottles of beer on the wall, no more bottles of beer.") s.append("Go to the store and buy some more, 99 bottles of beer on the wall.") return '\n'.join(s) n = int(input()) s = input().strip() if s == "Hello, World!": print("H") else: song = generate_99_bottles() if s == song: print("9") else: q_count = s.count('Q') if q_count == 1: valid = True for c in s: if c == 'Q': continue if c in {'H', 'Q', '9'}: valid = False break if valid: print(s) else: print(-1) else: print(-1)