The king of the Sky-Dragon Kingdom likes the trading of houses. If there are some houses on sell, he buys the houses and sells them at high price. If there are no houses on sell, he will buy some land to build houses and then sell all them.
One day, the king wants to do something interesting. Since he loves the business transaction between houses so much, he decides to hold a big business that all people in the kingdom to trade their houses between each other.
There are N people in the kingdom, all they have his own house. There are K types of house, and the type of the each N houses is one of them.
In order to make sure that the big trading business is going on well, the kings make the price of each type of house. All the price of the N houses should comply with the rule of the king. After making the prices, the king will first buy all the N houses and sell them to the N people with the same price.
To avoid people unhappy, the N people give their preference list of the types of house. And the king wants to make prices of each type of house such that all N people each can buy a house and all houses are sold. And for each people, the type of the house he buys is in his preference list and it's the favorite type in the types whose price is no more than his originally own house. That is, after obtaining the money by selling his house, he buys the house of favorite type in all the types he can pay with the money.
Please write a program to help the king that gives the type of house each N people own, and their preference list, tell the king if it's possible to make a price of each type of house?
The first line of the input file contains an integer T (T ≤ 20) indicating the number of
test cases. For each test case, the first line contains two integers N and K (1 ≤ N,K ≤ 30000), the number of people and number of types. The types are numbered from 1 to K. In the i-th line of following N lines, the first integer is the type of his own house of i-th people, the second integer mi (1 ≤ mi ≤ 50) is the length of his preference list and following mi integer are the types of his list start from the favorite one in order.
For each test case, output 'Y' if it's possible to make a price for each type in a
single line. Otherwise output 'N'.