#K79262. Landing Priorities

    ID: 35270 Type: Default 1000ms 256MiB

Landing Priorities

Landing Priorities

You are given a list of flights, each represented by two integers: the fuel level and the flight duration. Due to emergency conditions, flights with lower fuel levels are prioritized for landing. In cases where multiple flights have the same fuel level, the flight with the longer duration is given higher priority. If both parameters are equal, the flight with the smaller original index lands first.

Your task is to determine the landing order for all flights. Formally, let each flight be represented by a pair \( (f, d) \), where \( f \) is the fuel level and \( d \) is the flight duration. You need to sort the flights by the key:

[ \text{key}(f, d) = \left( f, -d, \text{index} \right) ]

and output the original indices of the flights in the sorted order.

inputFormat

The input is given via stdin and is formatted as follows:

  • The first line contains a single integer \( n \) indicating the number of flights.
  • The next \( n \) lines each contain two space-separated integers. The first integer represents the fuel level, and the second represents the flight duration of a flight.

outputFormat

Output a single line to stdout containing the indices of the flights in their landing order separated by spaces.

## sample
5
5 120
4 100
3 180
5 130
2 90
4 2 1 3 0

</p>