Long words X74969


Statement
 

pdf   zip

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

Public test cases
  • Input

    2 4
    truck
    truck
    bike
    plane
    
    

    Output

    bike
    truck
    
  • Input

    2 5
    truck
    bike
    truck
    plane
    

    Output

    plane
    truck
    
  • Input

    3 5
    truck
    car
    bike
    plane
    

    Output

    Goal not attained
    
  • Information
    Author
    ProAl
    Language
    English
    Official solutions
    Python
    User solutions
    Python