## ChongQueue

I solemnly introduce to you a new kind of species ---- bugs (of course not worms on your earth). I am a member of the population. We live in the Chongplanet, which is a well-developed planet. Sometimes my friends and I play with you programmer, but you  often can't find us where, so foolish. Oh, I have not told you my name,you can called me ChongChong.
There are many interesting things on Chongplanet. Although Chongplanet was developed vary well, some places still need to queue. How can it be same with queue on earth? Thinking of queue at my school, we have a lot of students each class. when I want to enqueue, I'll find whether there are my classmates in the queue or not. If yes, I can insert behind my classmates (you human are not allowed to jump the queue, so foolish); If not, then I can only stand behind the whole queue.
Even allowed to jump the queue, Bugs also complained about queuing. I thought of a solution. Simulate the queue with a program, so that Bugs do not need stand in the queue. This is your task. We Bugs are clever, so it's foolish people's task to write such a low-level program.

The input file will contain one or more test cases. Each test case begins with the number of classes t ( 1 <= t <= 1000). Then t classes descriptions follow, each one consisting of the number of students belonging to the class and the students themselves. A class may consist of up to 1000 students. Students are string, the length of which is in the range [1, 10).

Finally, a list of commands follows. A test case may contain up to 100000 commands. There are three different kinds of commands:

ENQUEUE x - enter student x into the queue
DEQUEUE - process the first student and remove it from the queue
STOP - end of test case

The input will be terminated by a value of 0 for t.

For each test case, first print a line saying Scenario #k", where k is the number of the test case. Then, for each DEQUEUE command, print the student which is dequeued on a single line. Print a blank line after each test case, even after the last one.

2
3 a b c
3 d e f
ENQUEUE a
ENQUEUE d
ENQUEUE b
ENQUEUE e
ENQUEUE c
ENQUEUE f
DEQUEUE
DEQUEUE
DEQUEUE
DEQUEUE
DEQUEUE
DEQUEUE
STOP
2
5 qqqqqq wwwwww eeeeee rrrrrr tttttt
6 aaaaaa ssssss dddddd ffffff gggggg hhhhhh
ENQUEUE qqqqqq
ENQUEUE aaaaaa
ENQUEUE wwwwww
ENQUEUE eeeeee
ENQUEUE rrrrrr
ENQUEUE tttttt
DEQUEUE
DEQUEUE
ENQUEUE ssssss
ENQUEUE dddddd
DEQUEUE
DEQUEUE
DEQUEUE
DEQUEUE
STOP
0

Scenario #1
a
b
c
d
e
f

Scenario #2
qqqqqq
wwwwww
eeeeee
rrrrrr
tttttt
aaaaaa


1718

old_judge

old_judge_None