#C13622. Find Anagrams

    ID: 43181 Type: Default 1000ms 256MiB

Find Anagrams

Find Anagrams

You are given a list of strings. The first string in the list is taken as the reference string. Your task is to find all the strings from the list (excluding the first string) that are anagrams of the reference string.

An anagram of a string is a rearrangement of its characters. For example, the anagrams of "listen" can be "silent", "enlist", and "inlets". Note that the order of letters matters only in the sense that both strings must have the exact same frequency of characters.

If there are no anagrams, output an empty string.

Input and Output Format:

The input is read from standard input (stdin) and the output should be written to standard output (stdout).

inputFormat

The first line contains a single integer n which represents the number of strings. The second line contains n space-separated words.

For example:

5
listen silent enlist google inlets

outputFormat

Print a single line containing the anagrams of the first input string (reference string) found in the rest of the list, separated by a single space. If there are no anagrams, print an empty line.

## sample
5
listen silent enlist google inlets
silent enlist inlets