During the prime time slot, television networks compete minute by minute to lead the audience ratings. From the data collected by audience meters, the number of viewers watching each channel at every instant is known.
Telemachus must analyze a time slot of $$$D$$$ minutes and determine for how long each channel has been the most watched. Specifically, the $$$D$$$ intervals $$$[m, m+1)$$$ are considered for $$$0 \le m \lt D$$$.
At minute 0, the initial audiences of all channels are known. Afterwards, updates are received: at certain minutes, the audience of some channels changes, remaining constant until the next update.
It is guaranteed that at every minute there is a unique channel with the maximum audience.
The following figure shows the evolution of the audiences in the sample input. The thicker segments indicate which channel leads during each interval.
The input begins with a line containing an integer $$$T$$$ indicating the number of test cases that follow.
Each case begins with three integers $$$D$$$, $$$C$$$, and $$$N$$$: the duration of the observed time slot (in minutes), the number of channels, and the number of updates.
Then:
$$$$$$ m\ u\ c_1\ e_1\ \dots\ c_u\ e_u $$$$$$ which indicates that at minute $$$m$$$ (with $$$0 \lt m \lt D$$$) a total of $$$u$$$ channels (with $$$u \gt 0$$$) change their state: the channels $$$c_1, \dots, c_u$$$ change their audiences to $$$e_1, \dots, e_u$$$, respectively, from that minute onwards.
Updates are given in strictly increasing order of minute, and no channel appears more than once within the same update.
For each case, print on separate lines every channel that has been the most watched for at least one minute, followed by the number of minutes it has led the audience.
Lines must be sorted by the number of minutes in decreasing order, and in case of a tie, by increasing channel identifier.
2120 3 59000 1000 1500015 2 1 13000 3 800030 1 3 1100045 2 1 9000 2 350060 1 1 14000100 3 2 5000 1 13000 3 1000090 3 20 0 10030 2 1 100 3 060 2 1 0 2 100
1 903 301 302 303 30
| Name |
|---|


