#K59902. Ticket Prioritization and Processing Order

    ID: 30967 Type: Default 1000ms 256MiB

Ticket Prioritization and Processing Order

Ticket Prioritization and Processing Order

You are given multiple test cases. In each test case, there are a number of customers, each with a ticket having an associated priority level. Your task is to determine the order in which the tickets should be processed. Tickets with lower priority numbers should be processed first. If two customers have the same priority, their order should remain the same as the input order (i.e., the sorting is stable). You can consider the ordering rule mathematically as follows: if customer i has priority \( p_i \) and customer j has priority \( p_j \), then customer i should come before customer j if \( p_i < p_j \).

inputFormat

The first line contains an integer \(T\) representing the number of test cases. For each test case:

  • The first line contains an integer \(N\), the number of customers.
  • The following \(N\) lines each contain a string and an integer, representing the customer ID and its associated priority level, respectively.

All inputs are read from standard input (stdin).

outputFormat

For each test case, output a single line containing the customer IDs sorted in ascending order of their priority levels, separated by spaces. The output is written to standard output (stdout).

## sample
1
5
customer1 10
customer2 5
customer3 12
customer4 8
customer5 1
customer5 customer2 customer4 customer1 customer3

</p>