#C3665. Task Management Scheduling

    ID: 47117 Type: Default 1000ms 256MiB

Task Management Scheduling

Task Management Scheduling

You are given a list of tasks, each associated with an employee, a task identifier, and an integer priority. The goal is to process the tasks in an order that minimizes the total waiting time by handling tasks with lower priority values first.

Formally, each task is represented as a triple \((employee, task, p)\), where \(p\) is the priority. You are required to output the sequence of task identifiers sorted in non-decreasing order of \(p\). In case of equal priorities, the input order should be preserved.

Note: The input consists of several test cases. Each test case starts with an integer \(T\) (the number of tasks), followed by \(T\) lines each containing the employee name, task identifier, and priority, separated by spaces. The input terminates when \(T = 0\), which should not be processed.

inputFormat

The input is read from stdin and consists of one or more test cases. Each test case begins with an integer \(T\) \((1 \le T \le 10^5)\), representing the number of tasks. The next \(T\) lines each contain three entries:

  • A string denoting the employee's name.
  • A string denoting the task identifier.
  • An integer \(p\) representing the task's priority.

The end of input is indicated by a test case with \(T = 0\), which should not be processed.

outputFormat

For each test case, output a single line to stdout containing the task identifiers arranged in the order of increasing priority, separated by a single space.

## sample
3
A X 5
B Y 2
C Z 1
0
Z Y X

</p>