The Carnival Ticket Machine
View as PDFThe Carnival Ticket Machine
Children line up for tickets. children (golden hats) are always served
before
children. Among the same type, earlier arrivals go first.
Output the order in which all children are served.
Your Task
Given children each tagged
or
, output their names in service
order (all
s in arrival order first, then all
s in arrival order).
Input Specification
The first line contains — the number of carnival days.
Each day starts with
on its own line, followed by
lines each containing
a name and type (
or
) separated by a space.
Output Specification
For each day print the names in service order, one per line.
Sample Input
1
4
Alice NORMAL
Bob VIP
Carol NORMAL
Dave VIP
Sample Output
Bob
Dave
Alice
Carol
Constraints
Names are unique strings of up to 30 characters.
Type is exactly or
.
Comments