beecrowd | 1348

X-Mart

By Guilherme Ottoni Brazil

Timelimit: 2

The well known supermarket chain X-Mart decided to cut costs, reducing the number of different products available in its shops’ shelves. The marketing department was concerned that this decision would affect sales, and decided to exploit the reduction of products to promote customer relations.

X-Mart therefore organized an Internet poll, in which customers could choose which products they wanted the supermarket to keep on their shelves, and which products they wanted the supermarket to withdraw from their shelves. The list of currently available products was published on the Internet.

To simplify the polling system, each customer was allowed to choose at most two products to vote for (meaning the supermarket should keep selling it) and at most two products to vote against (meaning the supermarket should stop selling it).

Once the marketing department got all the votes in its database, it wants to know if it is possible to choose a new list of products that pleases ALL voting customers. The marketing department considers that a customer will be pleased when at least one of the products she/he voted for was indeed kept by the supermarket, and at least one of the products she/he voted against was withdrawn from the supermarket’s shelves. You may assume a customer does not vote for and against the same product.

Input

Your program should process several test cases. The first line of a test case contains two integers C and P, representing respectively the number of customers and the number of products in the test (1 ≤ C ≤ 1000 and 1 ≤ P ≤ 10000). Each of the next C lines describes the preference of one customer, represented as four integers X, Y, S and T (0 ≤ X, Y, S, TP). X and Y are products the customer wants the supermarket to keep selling, S and T are products the customer wants the supermarket to stop selling. A zero value for any of the variables X, Y, S and T means the customer is not making use of that vote. A line with C = P = 0 indicates the end of input.

Output

For each test case your program must print one line, containing either the word ‘yes’ (if it is possible to please all voting customers) or the word ‘no’ (if it is not possible).

Sample Input Sample Output

3 4
1 2 3 4
3 4 1 2
2 3 1 4
4 4
1 2 3 4
3 4 1 2
1 3 2 4
1 4 2 3
4 4
1 2 3 4
3 4 1 0
1 3 2 4
2 4 0 3
0 0

yes
yes
no