#K92887. To-Do List Manager

    ID: 38297 Type: Default 1000ms 256MiB

To-Do List Manager

To-Do List Manager

You are given a set of commands to manage a to-do list. The to-do list supports three operations:

  • add task_name priority: Adds a task with the given task_name and priority, and assigns it a unique ID starting from 1. Each new task gets an ID that is 1 greater than the previous one.
  • delete task_id: Removes the task with the specified task_id from the list. If the task is not found, do nothing.
  • list: Outputs all the current tasks sorted in \(\text{increasing order of priority}\) and then by \(\text{increasing order of task ID}\) if priorities are equal. Each task is printed in the format id task_name priority.

The sorting criterion can be formally represented as follows: For two tasks with ids \(i\) and \(j\), and priorities \(p_i\) and \(p_j\), task \(i\) comes before task \(j\) if \(p_i < p_j\) or \(p_i = p_j\) and \(i < j\).

Your task is to implement the to-do list manager that processes a series of commands read from standard input and outputs the results of the list command to standard output.

inputFormat

The input will be read from standard input. The first line contains an integer N indicating the number of commands. Each of the next N lines contains a command. The commands are one of the following formats:

  • add task_name priority
  • delete task_id
  • list

outputFormat

For each list command, output the current tasks with each task on a new line in the format id task_name priority. The results for multiple list commands should be concatenated in order.

## sample
5
add task1 2
add task2 1
list
delete 1
list
2 task2 1

1 task1 2 2 task2 1

</p>