Long words X91958


Statement
 

pdf   zip

thehtml

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 n and the goal length m; they are integers coming in the first line. Then finds out whether the text that follows them contains at least n different words of length at least m. If so, it outputs the n words, sorted according to the standard string ordering, each in a line. Otherwise, it prints Goal not attained.

Input

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

Output

In case the goal is achieved, the output consists of n lines with the n first different words in the input text whose length is at least m. 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
    Language
    English
    Official solutions
    Python
    User solutions
    Python