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
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    map<vector<int>,int> mp;
    rep(i,n){
        int w;
        cin>>w;
        vector<int> a={0,1,2};
        rep(j,w){
            int x;
            cin>>x;
            if(x)swap(a[1],a[2]);
            else swap(a[1],a[0]);
        }
        mp[a]++;
    }
    bool ok=false;
    if(mp[{0,1,2}])ok=true;
    if(mp[{0,2,1}]>=2)ok=true;
    if(mp[{1,0,2}]>=2)ok=true;
    if(mp[{2,1,0}]>=2)ok=true;
    if(mp[{1,2,0}]>=3)ok=true;
    if(mp[{2,0,1}]>=3)ok=true;
    if(mp[{1,2,0}]>=1&&mp[{2,0,1}]>=1)ok=true;
    if(mp[{0,2,1}]&&mp[{1,0,2}]&&mp[{1,2,0}])ok=true;
    if(mp[{0,2,1}]&&mp[{1,0,2}]&&mp[{2,0,1}])ok=true;
    if(mp[{2,1,0}]&&mp[{1,0,2}]&&mp[{1,2,0}])ok=true;
    if(mp[{2,1,0}]&&mp[{1,0,2}]&&mp[{2,0,1}])ok=true;
    if(mp[{0,2,1}]&&mp[{2,1,0}]&&mp[{1,2,0}])ok=true;
    if(mp[{0,2,1}]&&mp[{2,1,0}]&&mp[{2,0,1}])ok=true;
    if(ok)cout<<"yes"<<endl;
    else cout<<"no"<<endl;
    return 0;
}
