initial_string = input().split()
move_counter = 0
command = input()
while command != "end":
command_split = command.split()
index_1 = int(command_split[0])
index_2 = int(command_split[1])
move_counter += 1
if 0 <= index_1 < len(initial_string) and 0 <= index_2 < len(initial_string):
value_1 = initial_string[index_1]
value_2 = initial_string[index_2]
if value_1 == value_2:
print(f"Congrats! You have found matching elements - {value_1}!")
initial_string.remove(value_1)
initial_string.remove(value_2)
else:
print(f"Try again!")
else:
print(f"Invalid input! Adding additional elements to the board")
middle_point = int(len(initial_string) // 2)
for el in range(move_counter):
initial_string.insert(middle_point, f"-{str(move_counter)}a")
if len(initial_string) == 0:
print(f"You have won in {move_counter} turns!")
break
command = input()
if len(initial_string) != 0:
print(f"Sorry you lose :(")
print(" ".join(initial_string))