Lines in order (2) P49603


Statement
 

pdf   zip

thehtml

Write a program that, given a sequence of lines with words, tells which is the last line that has the words in increasing (lexicographic) order.

Input

Input consists of a sequence of lines with words. Each line begins with a number n, followed by n words made up of only lowercase letters.

Output

Print the index of the last line with the words in (not necessary strictly) increasing order. If there is no such line, tell so. Follow the format of the examples.

Public test cases
  • Input

    5 i am not in order
    2 neither me
    4 i yes yes yes
    1 idem
    

    Output

    The last line in increasing order is 4.
    
  • Input

    4 one two three four
    5 e d c b a
    

    Output

    There is no line in increasing order.
    
  • Input

    0
    

    Output

    The last line in increasing order is 1.
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++ Java Python
    User solutions
    C C++ Java Python