#K14711. Find Anagrams

    ID: 24196 Type: Default 1000ms 256MiB

Find Anagrams

Find Anagrams

Given a word and a list of candidate words, determine which candidate words are anagrams of the given word.

Two words are anagrams if one can be rearranged to form the other by using all the original letters exactly once. In this problem, you are required to find all the candidate words that are anagrams of the given word. If no candidate word forms an anagram, output No anagrams found.

Note: The solution must read input from stdin and output the result to stdout.

You are also required to support multiple test cases as defined in the input format.

inputFormat

The input consists of two lines:

  1. The first line contains the target word, which is a string of lowercase letters.
  2. The second line contains a list of candidate words separated by spaces.

Read the input from stdin.

outputFormat

Output a single line to stdout:

  • If one or more anagrams are found, print them in the order they appear in the candidate list, separated by a space.
  • If no anagrams are found, print exactly No anagrams found.
## sample
listen
enlist google inlets banana silent
enlist inlets silent

</p>