In previous meetings of the Independent Organization for Epizootics, also known as the World Organization for Animal Health, everyone gathered in Barcelona to discuss the most relevant topics. However, every year several problems arose.
The problem occurred when it was time for dinner; several options were always proposed for dinner: a dining hall at the meeting venue, a café a little south of the location, or the pizzeria on the corner. But this was not the problem, as the attendees could not choose and always went to the pizzeria.
The issue they faced was that they never knew if they could buy pizzas to satisfy all the diners without any leftovers.
The pizzeria sells $$$M$$$ different pizza toppings numbered from $$$0$$$ to $$$M-1$$$. Each pizza is divided into 8 slices, and a pizza has only one topping.
There are $$$N$$$ people attending the meeting, and each person wants to eat $$$p_i$$$ slices of pizza.
The organization wants to know if, given the slices that the attendees want to eat, it is possible to buy a number of pizzas such that no food is wasted.
The input consists of several cases. Each case consists of several lines.
Each case begins with two integers $$$N$$$, $$$M$$$. The number of attendees and the number of pizza toppings offered by the pizzeria.
This is followed by $$$N$$$ lines, each line beginning with a number $$$p_i$$$, the number of slices that the i-th person wants to eat, followed by $$$p_i$$$ integers $$$t_{ij}$$$ indicating the toppings they want for their slices. A person may want more than one slice with the same topping.
For each case, you must print SI if it is possible to buy pizzas without wasting food, or NO if it is not possible. Each case must be printed on a different line.
$$$ 1 \leq N \leq 1000 $$$
$$$ 1 \leq M \leq 100 $$$
$$$ 1 \leq p_i \leq 10^5 $$$
$$$ 0 \leq t_{ij} \leq M-1 $$$
For each case, the sum of $$$p_i$$$ does not exceed $$$10^5$$$
Subtasks
Subtask 1 (15pt):
$$$ M = 1, N = 1 $$$
Subtask 2 (20pt):
$$$ M = 1 $$$
Subtask 3 (65pt):
No additional restrictions
1 1 8 0 0 0 0 0 0 0 0 5 1 1 0 2 0 0 3 0 0 0 2 0 0 1 0 3 3 3 0 1 2 3 2 2 0 3 1 1 1
SI NO NO