Files
kattis/spellingbee.py
2023-07-17 22:40:25 +02:00

20 lines
366 B
Python

letters = input()
n = int(input())
def check_word(word: str, letters: str) -> bool:
for letter in word:
if letter not in letters:
return False
return True
for _ in range(n):
word = input()
if 4 > len(word):
continue
if letters[0] not in word:
continue
if check_word(word, letters):
print(word)