The supermarket of the army

Simulate the behaviour of the queues of the supermarket of an army headquarter. Initially, there are nn queues (1,2,,n1, 2, \ldots, n), each one with its customers. Afterwards, two things can happen:

Input

The input starts with the number of queues nn (a natural strictly positive). nn lines follow, one per line, each one with its customers (a word) and their graduations ("soldier", "sergeant", "captain", or "colonel"), in the order that they have arrived to que queue. After a line in white comes and a series of events, one per line: the word "ENTER" followed by the customer, the graduation, and the queue which he arrives to, or the word "LEAVE" followed by the queue which he leaves.

Output

First, your program must print the name of the customers that leave the queues, in the order that they left. After, it must print the final content of the nn queues, each one from the beginning to the end. Follow the format of the instance.

Hint: Use the instructions getline(cin, st) (where st is a string) to read a line, and istringstream iss(st); to create a stream iss which you can read the names and graduations from, iss >>>> nam >>>> gra;, where nam and gra also are strings. Be careful with the first getline you do, that will correspond to the line where the number nn is.

Autor: Salvador Roura

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T12:08:42.425Z

© Jutge.org, 2006–2026.
https://jutge.org