#C2750. Find Anagrams

    ID: 46101 Type: Default 1000ms 256MiB

Find Anagrams

Find Anagrams

You are given a list of words and a target word. Your task is to find all words from the list that are anagrams of the target word. Two words are anagrams if for every character c, the frequency in both words is the same; in mathematical form, for each character c we require that
$$\mathrm{count}(c,\; word)=\mathrm{count}(c,\; target)$$

If there are no anagrams in the list, output []. Otherwise, print the anagrams in the order they appear in the input, separated by a single space.

inputFormat

The input is given via standard input (stdin) and has the following format:

  1. An integer \(n\) representing the number of words in the list.
  2. The next \(n\) lines each contain one word.
  3. The last line contains the target word.

outputFormat

Output via standard output (stdout) a single line containing all anagrams of the target word separated by a single space. If there are no anagrams, output [].

## sample
5
listen
silent
enlist
google
facebook
silent
listen silent enlist