n = int(input())words = [] # word на words заменить лучше.for _ in range(n) word = input() words.append(word)for word in words # word in words, а не word in word ...