In Ada Land a common pastime is the card game Reppoh Ecarg. It is played with a deck of cards which contains cards each with a positive integer value written on it. The game’s rules are very simple. First, you pick a card with any number written on it. The value of the next card you pick must be a factor of this card’s value, or must have this card’s value as a factor of its own. The game continues until all possible jumps from one card to another have been completed, in which case the player wins, or until there are no more legal moves, in which case the player loses. Keep in mind that a jump from card to card invalidates a jump from card to card .
Unfortunately, there has recently been a malfunction in the factory that produces the Reppoh Ecarg decks, and some cards have been misprinted; some of the cards have had wrong numbers printed on them. You have been tasked with discarding all the unbeatable decks. Can you do it?
The first line will contain , the number of decks.
There will follow deck descriptions.
The first line of each deck will contain and .
The next line will have space separated integers, no greater than .
lines of one string,
Keep if the deck is beatable or
Discard if it is not.
Sample Input 1
1 5 6 1 2 3 4 6
Sample Output 1
Sample Input 2
2 6 6 1 2 2 3 3 6 3 3 1 2 3
Sample Output 2