Special Services

No attempts yetTime limit3sMemory limit256 MB

Problem

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.

  • No active booking uses that identifier.
  • The given employees can cover all demands of the currently active bookings together with the demands of the new booking.

A cancellation is accepted if and only if there is an active booking with that identifier.

Input

The first line contains TT, the number of test cases. Each test case starts with a line containing NN and BB, the number of employees and the number of bookings and cancellations in that test case.

Then follow NN lines, one per employee. Each line consists of a number cc followed by cc strings separated by whitespace, giving the names of that employee's qualifications.

Then follow BB lines, each holding either a booking or a cancellation. A booking starts with the word book, followed by the numeric identifier II of that booking, then the number dd, then dd 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 II of the booking to cancel.

  • 0<T500 < T \le 50
  • 1N2001 \le N \le 200
  • 1B10001 \le B \le 1000
  • 1c161 \le c \le 16
  • 0d160 \le d \le 16
  • 0I10000 \le I \le 1000
  • A qualification name is at most 10 characters long. At most 100 different qualifications appear among all employees.
  • An active booking is one that has been accepted and not yet successfully cancelled.
  • A booking may reserve no people whatsoever. The company manager handles those bookings, and you should keep on asking no questions.
  • The input and the output are large, so use fast reading and writing.

Output

For each booking and each cancellation, print one line. Print Accepted if the request is accepted, and Rejected otherwise.