Problem: Problem

There are $ N $ Amidakuji with 3 vertical lines.
No matter which line you start from, the Amidakuji that ends at the starting line is considered a good Amidakuji.
You can select one or more Amidakuji and connect them vertically in any order.
Output "yes" if you can make a good Amidakuji, otherwise output "no".

There are $ w_i $ horizontal lines in the $ i $ th Amidakuji.
$ a_ {i, j} $ indicates whether the $ j $ th horizontal bar from the top of Amidakuji $ i $ extends from the central vertical line to the left or right.
If $ a_ {i, j} $ is 0, it means that it extends to the left, and if it is 1, it means that it extends to the right.

Constraints

The input satisfies the following conditions.

* $ 1 \ le N \ le 50 $
* $ 0 \ le w_i \ le 100 $
* $ a_ {i, j} $ is 0 or 1

Input

The input is given in the following format.


$ N $
$ w_1 $ $ a_ {1,1} $ $ a_ {1,2} $ ... $ a_ {1, w_1} $
$ w_2 $ $ a_ {2,1} $ $ a_ {2,2} $ ... $ a_ {2, w_2} $
...
$ w_N $ $ a_ {N, 1} $ $ a_ {N, 2} $ ... $ a_ {N, w_N} $


All inputs are given as integers.
$ N $ is given on the first line.
$ W_i $ and $ w_i $ $ a_ {i, j} $ are given on the following $ N $ line, separated by blanks.

Output

If you can make a good Amidakuji, it outputs "yes", otherwise it outputs "no".

Examples

Input

3
2 0 0
1 1
5 1 0 0 1 0


Output

yes


Input

2
1 1
1 0


Output

no

Solution (in PYTHON3):

Solution:
N = int(input())
SET = [0,0,0,0,0,0]
judge = [[2,1,3],[1,3,2],[3,2,1],[2,3,1],[3,1,2],[1,2,3]]
for _ in range(0,N):
    ID = [1, 2, 3]
    amida = [int(x) for x in input().split()]
    for j in range(1,len(amida)):
        if amida[j] == 0:
            ID[0],ID[1] = ID[1],ID[0]
            #print(ID)
        elif amida[j] == 1:
            ID[1],ID[2] = ID[2],ID[1]
            #print(ID)

    for i in range(0,len(judge)):
        if ID == judge[i]:
            SET[i] += 1

#print(SET)

if ((SET[5] > 0) or (SET[0] > 1) or (SET[1] > 1) or (SET[2] > 1) or
        ((SET[0] > 0) and (SET[1] > 0) and (SET[4] > 0)) or
        ((SET[0] > 0) and (SET[2] > 0) and (SET[4] > 0)) or
        ((SET[0] > 0) and (SET[2] > 0) and (SET[4] > 0)) or
        ((SET[0] > 0) and (SET[1] > 0) and (SET[3] > 0)) or
        ((SET[0] > 0) and (SET[2] > 0) and (SET[3] > 0)) or
        ((SET[1] > 0) and (SET[2] > 0) and (SET[4] > 0)) or
        ((SET[3] > 0) and (SET[4] > 0)) or
        (SET[3] > 2) or (SET[4] > 2)):
    print("yes")
else:
    print("no")