#C766. Project Queue Simulation

    ID: 51555 Type: Default 1000ms 256MiB

Project Queue Simulation

Project Queue Simulation

Tim is assigned a number of projects, each characterized by a priority and a time of assignment. Projects with a higher priority should be executed first. In cases where two projects share the same priority, the project that was assigned earlier (i.e. with a smaller time value) will be processed first.

Your task is to simulate this scheduling system. You will be given an integer n representing the number of projects, followed by n lines where each line contains two integers: the project priority and the time of assignment.

Print the projects in the order they are worked on, with each project printed on a separate line in the format: priority time.

The ordering rule is defined as follows:

  • Projects with a higher priority are processed first.
  • If two projects have the same priority, the one with the earlier time (smaller value) comes first.

The sorting mechanism can be represented mathematically as:

\[ \text{For projects } i \text{ and } j, \quad i \text{ comes before } j \text{ if } (p_i > p_j) \text{ or } (p_i = p_j \text{ and } t_i < t_j). \]

inputFormat

The first line contains an integer n, the number of projects.

The next n lines each contain two space-separated integers: priority and time.

outputFormat

Output n lines, each containing two space-separated integers representing the project’s priority and time, in the order in which the projects are processed.

## sample
4
5 1
3 2
5 3
4 4
5 1

5 3 4 4 3 2

</p>