Long words

Write a program that checks whether a given text reaches a goal number of words of at least a given goal length. The program reads first the goal number nn and the goal length mm; they are integers coming in the first line. Then finds out whether the text that follows them contains at least nn different words of length at least mm. If so, it outputs the nn words, sorted according to the standard string ordering, each in a line. Otherwise, it prints Goal not attained.

Input

Input consists of two numbers nn and mm, being respectively the goal number and the goal length, followed by a sequence of words. Numbers nn and mm are integers, nn is greater than zero and mm is non negative.

Output

In case the goal is achieved, the output consists of nn lines with the nn first different words in the input text whose length is at least mm. Words are shown according to the standard string order, one by line. When goal is not reached, a line with the message Goal not attained

Problem information

Author: ProAl

Generation: 2026-01-25T17:16:23.966Z

© Jutge.org, 2006–2026.
https://jutge.org