#C3171. Taco Books Selection

    ID: 46569 Type: Default 1000ms 256MiB

Taco Books Selection

Taco Books Selection

Marie is an avid reader who faces the decision of which books to keep. She has n books, each having a unique identifier and a price. Marie wants to keep the k most expensive books. When two books have the same price, the book with the smaller identifier is preferred.

If the total number of books is less than k, then all books are kept. Finally, the selected book identifiers must be printed in ascending order.

The selection process can be formally described as follows:

Sort the books by price in descending order. In case of ties, sort by identifier in ascending order. Then choose the first k books from this sorted list and output their identifiers in ascending order.

Note: All inputs will be read from standard input and outputs should be printed to standard output.

inputFormat

The first line contains two integers n and k (1 ≤ n, k ≤ 105), separated by a space.

The following n lines each contain two integers: the book identifier and its price. Each identifier is unique (or may be duplicate as in some test cases) and the price is an integer.

Input is given via standard input (stdin).

outputFormat

Output a single line containing the identifiers of the selected books, sorted in ascending order and separated by a single space. The output should be printed to standard output (stdout).

## sample
5 3
101 25
102 30
103 25
104 30
105 20
101 102 104