You are to write a program that simulates a ticket counter queue.
At the start, no one is in the queue. As time goes on, customers start coming in and queues at the end, each intending to buy a specific number of tickets. The ticket counter then serves them starting from the front of the queue. When a transaction is completed, the served customer leaves the queue. Similar to the real world, selfish customers at time appears and cut the queue.
Your programs should take in a line containing an integer M on the number of subsequent input lines, and then M lines containing:
These event line and command line formats are described in more details in the following.
Your program MAY include <string>, <iostream>, <cassert>, <cstdio>, and <cstdlib>. You MUST NOT include any other C++ standard library headers.
A first line containing the number M, where 0 < M <= 1000000.
The remaining lines are either a command or an event.
For parameters N and P, 0 < N <= 1000000 and 0 <= P <= 1000000.
You can assume that the P position will always be already taken when a new selfish customer cuts at position P. You can also assume that there will be at least one customer when a customer is served.
For each print command, output the corresponding state of queue.
(Note that the first line of sample output contains a space character, but your program should not print any space character if the current queue is empty.)