Simulate the behavior of the queues of a supermarket. Initially, there are n queues (1, 2, …, n), each one with some customers. Afterwards, two events can happen:
Input
Input starts with the number of queues n (a strictly positive natural number). Follow n lines, one per queue, each one with its customers (a word) and their ages (a real number). Follow an empty line and the description of several events, one per line: the word “ENTERS” followed by the customer, the customer’s age, and the queue; or the word “LEAVES” followed by the queue. All the customers have different ages.
Output
First, print the name of the customers that leave the queues, in the order that they departed. Afterwards, print the final content of the n queues, using the order in which the customers would leave. Follow the format of the example.
Input
4 Cristina 10 Tomas 27 Francesc 70 Damia 25.5 Domenec 80 Teresa 19 Toni 83 Carles 24 LEAVES 1 LEAVES 1 ENTERS Amalia 30 4 LEAVES 2 LEAVES 1 ENTERS Leo 22 1 ENTERS Maria 20 3 LEAVES 4 LEAVES 4 LEAVES 3 ENTERS Carme 18 4 LEAVES 2 LEAVES -1 LEAVES 2
Output
DEPARTS ------- Tomas Cristina Domenec Toni Amalia Maria Francesc Damia FINAL CONTENTS -------------- queue 1: Leo queue 2: queue 3: queue 4: Carles Teresa Carme