Fun Coloring#3097

Fun Coloring

10 seconds
256 megabytes
Medium

Given: A finite set and sets \textbf{S}_1, \textbf{S}_2, \textbf{S}_3,\ldots, \textbf{S}_m such that each \textbf{S}_i is a subset of and |\textbf{S}_i| \leq 3.

Question: Is there a function \textbf{f}: \textbf{U} \to \{RED, BLUE\} such that in each set \textbf{S}_i, at least one element is assigned a color different from the others?

Given an instance of the Fun Coloring Problem, your task is to determine whether such a function exists for the given instance.

Input

In this problem \textbf{U} = \{x_1, x_2, x_3,\ldots,x_n\}. There are instances of the problem. The first line of the input file contains a single integer , and the following lines describe instances, each instance separated by a blank line. In each instance, the first line contains two integers and separated by a space. The next lines each describe a set: the th of these lines contains some integers representing x_i in \textbf{S}_j, each separated by a space. After lines, a blank line follows before the next instance (if any), and so on until the th instance is described. In all test cases, 1 \leq k \leq 13, 4 \leq n \leq 22, and 6 \leq m \leq 111.

Output

For each instance, if the function exists, print **Y**. Otherwise, print **N**. Your solution should be a single line containing characters (**Y** or **N**) without spaces. The th character is the answer for the th instance.

Examples

Example 1

Loading
Loading