Question and Answer from L4-M1
text = input().strip()
first = input().strip()
second = input().strip()
words = text.split()
result = []
for i in range(len(words) - 2):
if words[i] == first and words[i+1] == second:
result.append(words[i+2])
print('\n'.join(result))