You are given the job of building a booking system for a special services company. The company runs all sorts of services, and you are told not to ask any questions. A few developers tried to build this system before you, but none of them can be found now, so you cannot ask them for help.
The system receives bookings and cancellations one at a time, and it must accept or reject each request immediately. Every booking lasts a whole day, and the part you are building keeps track of a single day.
The company has a number of employees, and each employee holds one or more qualifications. Every booking has a numeric identifier and demands a number of people, each with a specific qualification. One person covers at most one demand from one booking during the whole day. The director gave Mario as an example: Mario can be both a plumber and an assassin, but in a single day he does only one of the jobs for one booking.
A booking is accepted if and only if both of the following hold.
A cancellation is accepted if and only if there is an active booking with that identifier.
The first line contains T, the number of test cases. Each test case starts with a line containing N and B, the number of employees and the number of bookings and cancellations in that test case.
Then follow N lines, one per employee. Each line consists of a number c followed by c strings separated by whitespace, giving the names of that employee's qualifications.
Then follow B lines, each holding either a booking or a cancellation. A booking starts with the word book, followed by the numeric identifier I of that booking, then the number d, then d strings separated by whitespace. Those strings are all the qualification demands of that booking. A cancellation consists of the word cancel followed by the identifier I of the booking to cancel.
For each booking and each cancellation, print one line. Print Accepted if the request is accepted, and Rejected otherwise.