#C12928. Find Anagrams

    ID: 42409 Type: Default 1000ms 256MiB

Find Anagrams

Find Anagrams

Given a target word and a list of candidate words, your task is to print all candidates that are anagrams of the target word. An anagram of a word is formed by rearranging its letters. The output should list each matching candidate on a separate line, in the same order as they appear in the input.

If no anagrams are found, the program should produce no output.

Note: The comparison is case-sensitive and even an empty string is considered a valid candidate if it is an anagram of the target word.

inputFormat

The input is read from standard input (stdin) and has the following format:

  1. The first line contains a string representing the target word.
  2. The second line contains a non-negative integer n, which is the number of candidate words.
  3. The following n lines each contain a candidate word.

outputFormat

The program should output all candidate words that are anagrams of the target word, each on a separate line. If there are no anagrams, output nothing.

## sample
listen
4
enlist
google
inlets
banana
enlist

inlets

</p>