#K66637. Optimal Delivery Sequence

    ID: 32465 Type: Default 1000ms 256MiB

Optimal Delivery Sequence

Optimal Delivery Sequence

A logistics company needs to deliver packages in an optimal sequence. Each package has a priority value and a distance value. The delivery strategy is to first deliver packages with a higher priority. In case of a tie in priority, the package with the smaller distance should be delivered first. The problem requires you to output the original 1-indexed order of delivery after sorting the packages by these rules.

Formally, given an integer (N) and (N) pairs ((p_i, d_i)) where (p_i) is the priority and (d_i) is the distance of the (i)-th package, you need to sort the packages in descending order of priority and, if two packages have the same priority, in ascending order of distance. Then, output the original indices of the packages in the new order.

inputFormat

The input is read from standard input (stdin).

The first line contains an integer (N) indicating the number of packages.
Each of the following (N) lines contains two space-separated integers: the priority and the distance of a package.

outputFormat

Output the optimal delivery sequence as a single line with the original 1-indexed package indices separated by spaces, written to standard output (stdout).## sample

3
2 100
1 50
2 30
3 1 2

</p>