# Returns True if partialWord "matches" word
def match(partialWord, word):
    if len(partialWord) != len(word):
        return False
    
    for i in range(len(word)):
        if partialWord[i].isalpha() and partialWord[i] != word[i]:
            return False
        
    return True

# main program
# upload the dictionary
f = open("dictionary.txt", "r")
dictionary = []
for line in f:
    dictionary.append(line.rstrip())
f.close()

# Read the partially specified word
partialWord = raw_input("Please input a word. Any missing letters may be represented by underscores. ")

# Look for partialWord in the dictionary
matchList = []
for word in dictionary:
    if match(partialWord, word):
        matchList.append(word)

print matchList