spoj#SOPARADE. Soldiers on Parade

Soldiers on Parade

Protocol is really weird in Byteland. For instance, it is required that, when presenting arms before an officer, soldiers should stand in a single row (at positions numbered from 1 to n). Soldiers may have one of 4 possible ranks, distinguished by the number of squiggles on the epaulets (between 1 and 4). Soldiers standing beside each other must have a difference in rank of at least two squiggles. Moreover, there are additional sets of rules (different for every province). Each rule states that soldiers standing at some given positions of the row must differ in rank by at least a squiggle.

Starting from the new year onwards, some provinces are changing their set of protocol rules. As the Senior Military Secretary of Protocol, it is your task to approve the new rules. To your surprise, some of the provinces have put forward protocol rules which are quite impossible to fulfill, even if the soldiers were to be specially selected for the purpose of presenting arms. Detect all such offending provinces and on no account approve their laws.

Input

The first line of input contains a single positive integer t<=10 - the number of provinces which are proposing new laws. t sets of rules follow, separated by empty lines.

Each set of rule begins with a line containing two non-negative integers n p (n<=100000, p<=100000) - the number of soldiers arranged and the number of rules proposed in the province, respectively. Each of the next p lines contains a single rule: an integer bi (2<=bi<=n), followed by bi integers a1,a2,...,abi (1<=ak<=n). Such a rule means that soldiers standing at positions a1,a2,...,abi must all be of different rank.

Output

For every set of rules presented at input, output a single line containing the word rejected if no unit of soldiers can be arranged in accordance with protocol, or the word approved in the opposite case.

Example

Input:
2

2 1
2 1 2

5 2
3 1 3 2
4 2 3 4 5

Output:
approved
rejected