synonyms = {}   # Define dictionary


# Read word and letter from user
word = input().strip()
letter = input().strip().lower()

# Open the text file associated with the input word
filename = word + '.txt'

try:
    with open(filename, 'r') as file:
        # Read all lines from the file
        lines = file.readlines()
        
        # Process each line
        for line in lines:
            # Split the line into individual synonyms
            words_in_line = line.strip().split()
            
            # Store each synonym in the dictionary using its first letter as key
            for synonym in words_in_line:
                first_char = synonym[0].lower()
                
                # Initialize list for this letter if it doesn't exist
                if first_char not in synonyms:
                    synonyms[first_char] = []
                
                # Add synonym to the list for this letter
                synonyms[first_char].append(synonym)
    
    # Check if there are synonyms for the input letter
    if letter in synonyms and synonyms[letter]:
        # Output all synonyms that begin with the input letter
        for synonym in synonyms[letter]:
            print(synonym)
    else:
        print(f"No synonyms for {word} begin with {letter}.")
        
except FileNotFoundError:
    print(f"File {filename} not found.")