import CGIHTTPServer
import cgi
import os
print "Content-type: text/html"
print

dir = os.path.dirname(os.path.realpath(__file__))
form = cgi.FieldStorage()

word = form["name"].value.upper()
word_len = len(word)
lines = open(dir+"\names.txt", "r").readlines()
names = [line.split()[0] for line in lines]
names.sort()

names_to_return = []

for name in names:
    if name[:word_len]==word:
        names_to_return.append(name)

print ', '.join(names_to_return)