HUST Monthly 2010.06.13

From: 2010-06-13 12:00:00 To: 2010-06-13 17:00:00 Now: 2017-09-20 01:00:11 Status: Public

B - Build Garden

Time Limit: 10s Memory Limit: 128MB

Submissions: 13 Solved: 6
One day, Farmer john go to a gardener’s house, and he is amazed by the house and the beautiful sight around this shed. so he decided to build a same garden like the gardener’s . For Farmer john don’t have such a great money, so he just want to the garden to be simple enough, there are just a little demands: First the garden should be built as a circle, which means you should put the N (N<100000) flower in the flowerpot one by one follow the circle. Second the flowers standing by each other should have a difference of color at least two (we define RED=1, YELLOW=2, BLUE=3, BLACK=4, and there is only four colors). And unfortunately, FJ’s son mike has see the plan, and he declare that he dislike the X1, X2...,Xm position in same color which means every one in the declaration should in different color (more formally , there is M(M<100000) limitation and every limitation is described as K x1 x2 … xk). So you have to consider these restrictions. Now FJ give the problem to you, can you solve this easy question? For simplify , you only have to tell FJ the plan is possible or not.
The first line is test case T(T<10) , the second line is N M ( N flowers and M restriction) , then followed M description written as K x1 x2 … xk. N<100000, M<100000. T<10
Just T simple words “YES” or “NO” by line ( “YES” means the plan is available, and “NO” means the plan is impossible !)
Sample Input
10 3
2 8 7 
1 6
2 6 3

10 3
1 8 
4 2 5 3 4 
4 6 10 2 5 
Sample Output
Hust Monthly 10.06.13/Jian HE