Jack’s company has a very long program to modify. Each programmer edits some lines of that program and cannot add or delete any lines. A programmer can do three kinds of operations as below:
- SYNC: At the beginning, every programmer must do this to download the whole program from the code center to their local machine. This operation only executes once for each programmer.
- MODIFY: Modify a line of the code. The modification work will be temporarily done on the local computer.
- SUBMIT: Submit one’s whole local code to the code center. The code center will handle all possible changes and then send the whole newest program back to the submitter. We assume that the time duration of handling changes and sending back can be omitted.
The code center records the time and the performer of every operation.
As you see, a programmer can get the program from the code center only when he performs a SYNC or a SUBMIT operation. We call the version in the code center “standard version.” The code center keeps only ONE standard version.
Imagining there are two programmers who download the same version of the program and they both modify the ith line. Then they both submit their programs. Now what will the ith line be in the standard version? Jack figures out a rule. He gives each programmer a unique priority. When a programmer (Let’s name him Tom) modifies the ith line and then submit his program, the code center will handle the content of the ith line following the rules below:
1. If there was no accepted modification on the ith line before, Tom’s modification will be accepted. That means, the ith line in the standard version becomes the same as the ith line in the program submitted by Tom, and so Tom becomes the author of this line.
2. Otherwise, if the time of the last accepted modification on the ith line, is earlier than the time when Tom got the program from code center last time (Tom can get the program by SYNC or SUBMIT operation), Tom’s modification will be accepted. This situation means that there was no newly accepted modification on the ith line during the time from the ith line’s last accepted modification to Tom’s submission.
3. Otherwise, if Tom’s priority is higher than the priority of the last author of the ith line, Tom’s modification will be accepted.
4. In other cases, Tom’s modification on the ith line this time will be ignored and never be processed again.
5. If Tom’s modification was accepted, the code center would record the modification time of the ith line as the time when Tom’s SUBMIT operation happened.
Please note that a programmer can modify multiple lines before he submits, and his modification on some lines may be accepted, but on the other lines may be ignored.
For example, Alice and Bob are two programmers. Alice’s priority is 1 and Bob’s is 2(2 is higher than 1). In following case A and B, Bob’s modification on the first line will be accepted. However, Alice’s modification will be ignored in Case C but will be accepted in Case D.
Case A
[2010/07/18 12:00:00] Alice SYNC
[2010/07/18 12:00:01] Bob SYNC
Alice and Bob are editing the first line.
[2010/07/18 12:05:00] Alice SUBMIT
[2010/07/18 12:06:00] Bob SUBMIT
Case B
[2010/07/18 12:00:00] Alice SYNC
Alice is editing the first line.
[2010/07/18 12:05:00] Alice SUBMIT
[2010/07/18 12:05:01] Bob SYNC
Bob is editing the first line
[2010/07/18 12:06:00] Bob SUBMIT
Case C
[2010/07/18 12:00:00] Alice SYNC
[2010/07/18 12:00:02]Bob SYNC
Alice and Bob are editing the first line.
[2010/07/18 12:05:00]Bob SUBMIT
[2010/07/1812:06:00]Alice SUBMIT
Case D
[2010/07/18 12:00:00] Bob SYNC
Bob is editing the first line.
[2010/07/18 12:05:00]Bob SUBMIT
[2010/07/18 12:05:01]Alice SYNC
Alice is editing the first line
[2010/07/18 12:06:00]Alice SUBMIT
You need to help Jack to figure out who is the last author of every code line in the final standard version of the program.