#C93. Find Anagrams

    ID: 53377 Type: Default 1000ms 256MiB

Find Anagrams

Find Anagrams

Given a target string and a list of candidate strings, your task is to find all strings from the candidate list that are anagrams of the target string. Two strings are anagrams if they contain exactly the same characters (order does not matter).

The input is read from standard input. The first line contains the target string. The second line contains an integer (N) representing the number of candidate strings. The following (N) lines each contain one candidate string.

Your program should output a single line with the candidate strings that are anagrams of the target, in the same order as they appear in the input, separated by a single space. If there are no anagrams, output an empty line.

inputFormat

The first line contains the target string. The second line contains an integer (N) denoting the number of candidate strings. The next (N) lines each contain one candidate string.

outputFormat

Output a single line containing the candidate strings that are anagrams of the target string separated by spaces. If there are no anagrams, output an empty line.## sample

listen
5
enlist
google
inlets
banana
silent
enlist inlets silent