#C13386. Sort Strings by Descending Length

    ID: 42918 Type: Default 1000ms 256MiB

Sort Strings by Descending Length

Sort Strings by Descending Length

You are given a list of strings. Your task is to sort the strings in descending order based on their lengths. If two strings have the same length, their original relative order should be preserved (i.e., the sort must be stable).

Formally, if the lengths of two strings are denoted by \(\ell(s)\), then for two strings \(s_1\) and \(s_2\), \(s_1\) should appear before \(s_2\) if either \(\ell(s_1) > \ell(s_2)\) or \(\ell(s_1) = \ell(s_2)\) and \(s_1\) precedes \(s_2\) in the original list.

Input will be provided via standard input (stdin) and the sorted result should be printed to standard output (stdout) with one string per line.

inputFormat

The input begins with a single integer n on the first line indicating the number of strings. Each of the next n lines contains one string.

outputFormat

Print n lines, each containing one string. The strings should be printed in order sorted by descending length. For strings of equal length, maintain their original order.

## sample
4
apple
banana
kiwi
grape
banana

apple grape kiwi

</p>