Language: C++

#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

map<vi,int> mp;
vvi vec[6];

bool dfs(vi nw,int* cnt,int pos,bool flag)
{
    if(pos == 6){
        return flag && (nw == vi{0,1,2});
    }
    rep(i,cnt[pos]){
        if(pos == 1){
            swap(nw[1],nw[2]);
        }else if(pos == 2){
            swap(nw[0],nw[1]);
        }else if(pos == 3){
            swap(nw[0],nw[2]);
        }else if(pos == 4){
            swap(nw[0],nw[1]);
            swap(nw[1],nw[2]);
        }else{
            swap(nw[0],nw[2]);
            swap(nw[1],nw[2]);
        }
        if(dfs(nw,cnt,pos+1,(flag|(i >= 1))){
            return true;
        }
    }
    return false;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    mp[vi{0,1,2}] = 0,mp[vi{0,2,1}] = 1,mp[vi{1,0,2}] = 2;
    mp[vi{2,1,0}] = 3,mp[vi{1,2,0}] = 4,mp[vi{2,0,1}] = 5;
    int cnt[6] = {};
    rep(i,n){
        vi st = {0,1,2};
        int a;
        cin >> a;
        rep(j,a){
            int c;
            cin >> c;
            if(c){
                swap(st[1],st[2]);
            }else{
                swap(st[0],st[1]);
            }
        }
        cnt[mp[st]]++;
    }
    if(cnt[0] >= 1){
        cout << "yes\n";
        return 0;
    }
    if(cnt[1] >= 2 || cnt[2] >= 2 || cnt[3] >= 2){
        cout << "yes\n";
        return 0;
    }
    if(cnt[4] >= 3 || cnt[5] >= 3){
        cout << "yes\n";
        return 0;
    }
    if(dfs(vi{0,1,2},cnt,0,false)){
        cout << "yes\n";
    }else{
        cout << "no\n";
    }
    return 0;
}



Compiler output:
a.cc: In function 'bool dfs(vi, int*, int, bool)':
a.cc:62:45: error: expected ')' before '{' token
   62 |         if(dfs(nw,cnt,pos+1,(flag|(i >= 1))){
      |           ~                                 ^
      |                                             )
a.cc:65:5: error: expected primary-expression before '}' token
   65 |     }
      |     ^