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 CPP):

Solution:
//----------------------------
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#include <bits/stdc++.h>
using namespace std;

//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;

int n,w,a,a1,a2,a3,amida[50],kind[6];

int main(){
    I(n);
    REP(i,n){
        a1 = 0;
        a2 = 1;
        a3 = 2;
        I(w);
        REP(j,w){
            I(a);
            if (a){
                swap(a2,a3);
            } else {
                swap(a1,a2);
            }
        }
        if (a1 == 0){
            amida[i] = a2 == 1 ? 0 : 1;
        } else if (a1 == 1){
            amida[i] = a2 == 0 ? 2 : 3;
        } else {
            amida[i] = a2 == 0 ? 4 : 5;
        }
    }
    REP(i,n) kind[ amida[i] ] ++;

    if (kind[0] || kind[1] >= 2 || kind[2] >= 2 || kind[5] >= 2 ||
        kind[3] >= 3 || kind[4] >= 3 || (kind[3] && kind[4]) ||
        ( (kind[3] + kind[4]) && (kind[0] + kind[1] + kind[5]) >= 2 ) ) {
            cout << "yes" << endl;
        } else{
            cout << "no" << endl;
        }
}