Language: C++

/** BISMILLAH, AR-RAHMAN, AR-RAHIM **
*** Giving up is the only sure way to fail ***

    Md. Mujahedul Azad (Turin)
    FB : FB/Md.turin01
    GH : GITHUB/turin1602101
    Hajee Mohammad Danesh Science & Technology University( H S T U ) */

#include<bits/stdc++.h>
using namespace std;

#define IL inline
#define ST template<int M>
#define TP template<class T>
#define UP template<class T, class U>
#define HP template<class H, class...T>

#define y0 sdkfaslhagaklsdfsfd
#define y1 aasdfasdfasdfsdfsdf
#define yn askfhwqriuperasdsdf

#pragma GCC target ("avx,avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#ifndef ONLINE_JUDGE
    #include "dbg.hpp"
#endif // ONLINE_JUDGE

//#include<ext/pb_ds/tree_policy.hpp>
//#include<ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//#define AT find_by_order // return iterator of index
//#define POS order_of_key // return position of value
//tplate struct pbds_cmp{bool operator()(const T &a, const T &b)const{return a < b;}};
//uplate using oset = tree<T,null_type,U,rb_tree_tag,tree_order_statistics_node_update>;

#define sq(x)           ((x)*(x))
#define cb(x)           ((x)*sq(x))
#define abs(x)          ((x)<0?-(x):(x))
#define max(a,b)        ((a)<(b)?(b):(a))
#define min(a,b)        ((a)<(b)?(a):(b))

#define gp              ' '
#define nl              '\n'
#define sc              scanf
#define ff              first
#define se              second
#define pf              printf
#define pc              putchar
#define G(a)            get<(a)>
#define gc              getchar()
#define pb              push_back
#define mp              make_pair
#define mt              make_tuple
#define lb              lower_bound
#define ub              upper_bound
#define eb              emplace_back
#define amax(a,b)       a = max(a,b)
#define amin(a,b)       a = min(a,b)
#define rint            register int
#define FLUSH           fflush(stdout)
#define all(x)          x.begin(),x.end()
#define rall(x)         x.rbegin(),x.rend()
#define Clr(x)          memset(x,0,sizeof(x))
#define Set(x)          memset(x,-1,sizeof(x))
#define fr(i,a,b)       for(rint i=a; i<b; i++)
#define rf(i,a,b)       for(rint i=b; i>=a; i--)
#define precision(x)    cout<<fixed<<setprecision(x)
#define fileIO(name)    freopen(name".in", "r", stdin);\
                        freopen(name".out", "w", stdout)

mt19937     rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64  rng64(chrono::steady_clock::now().time_since_epoch().count());
TP IL bool read(T&);IL bool read(char&);IL bool read(char*);HP IL bool read(H&,T&...);
TP IL void write(T);IL void write(char);IL void write(char*);IL void write(const char*);HP IL void write(H,T...);
TP IL T gcd(T,T);TP IL T lcm(T,T);TP IL T power(T,T);TP IL T MulL(T,T,T);TP IL T power(T,T,T);TP IL T powerL(T,T,T);
TP IL void in(T*,size_t);TP IL void in(vector<T>&,size_t);TP IL void out(T*,size_t);TP IL void out(vector<T>&,size_t);
const int dx[] = {1,-1,0,0,-1,1,-1,1}, dy[] = {0,0,-1,1,1,1,-1,-1}, kx[] = {-2,-1,1,2,2,1,-1,-2}, ky[] = {1,2,2,1,-1,-2,-2,-1};
const int MODF = 998244353, MOD7 = 1000000007, MOD9 = 1000000009, INF = 0x3f3f3f3f; const long double EPS = 1e-9, PI = acos(-1.0);
using tpl=tuple<int,int,int>;using ll=long long;using ld=long double;using vl=vector<ll>;using vi=vector<int>;using ii=pair<int,int>;using iii=pair<int, ii>;
IL int rand(int,int);IL ll randLL(ll,ll);IL void inRand(int*,int,int,int);void inRandLL(ll*,int,ll,ll);IL void inRand(vi&,int,int,int);IL void inRandLL(vl&,int,ll,ll);
ST struct Calculator{IL ll Inv(ll);IL ll Add(ll,ll);IL ll Sub(ll,ll);IL ll Mul(ll,ll);IL ll Div(ll,ll);};

Calculator<MOD7> C;
const int mx = 1e6+10;

int n, vis[15];
vector<ii> g[15];

bool ok = true;
void dfs(int i, int msk){
    vis[i] = 1;
    for(auto v:g[i]){
        int u = v.ff;
        int ase = (msk>>u) & 1;
        if(v.se && ase==0) {ok=0; return;}
        if(v.se==0 && ase) {ok=0; return;}
        if(v.se && !vis[u]) dfs(u, msk);
    }
}

IL void MAIN(int &cs){
//    write("Case ", cs, ": ");
    read(n);
    fr(i, 0, n){
        int m, l, r; read(m);
        fr(j, 0, m){
            read(l,r); l--;
            g[i].eb(l, r);
        }
    }

    int ans = 0;
    fr(i, 1, (1<<n)){Clr(vis); ok = true;
        fr(j,0,n) if((i&(1<<j)) && !vis[j]) dfs(j,i);
        if(!ok) continue;
        amax(ans, __builtin_popcount(i));
    }
    write(ans, nl);
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    precision(20); srand(time(nullptr));

    int tc = 1; ///read( tc );
    fr(cs, 1, tc+1) MAIN(cs);
    return 0;
}

char os[25];TP IL void in(T *a,size_t n){fr(i,0,n)read(a[i]);}TP IL void in(vector<T> &a,size_t n){fr(i,0,n)read(a[i]);}TP IL void out(T *a,size_t n){fr(i,0,n)write(a[i],(i+1==n)?nl:gp);}TP IL void out(vector<T> &a,size_t n){fr(i,0,n)write(a[i],(i+1==n)?nl:gp);}
ST IL ll Calculator<M>::Add(ll x,ll y){return (x+y)%M;}ST IL ll Calculator<M>::Inv(ll x){return power<ll>(x,M-2,M);}ST IL ll Calculator<M>::Sub(ll x,ll y){return (((x-y)%M)+M)%M;}ST IL ll Calculator<M>::Mul(ll x,ll y){return ((x%M)*(y%M));}ST IL ll Calculator<M>::Div(ll x,ll y){return Mul(x,Inv(y));}
TP IL void write(T x){if(x==0){pc('0'); return;}int i=0; bool neg=(x<0);if(neg)pc('-'),x=-x;while(x>0) {os[i++]=(x%10)+'0';x/=10;}i--; while(i>=0) pc(os[i--]);}IL void write(char *s){pf("%s",s);}IL void write(const char *s){pf("%s",s);}IL void write(char c){pc(c);}HP IL void write(H h, T ...t){write(h); write(t...);}
TP IL bool read(T &val){val=0;bool neg=0;char ch=gc;while(ch <'0' || ch >'9'){if(ch=='-') neg=1;else if(ch==EOF)return 0;ch=gc;}while(ch>='0' && ch<='9'){val=(val*10)+(ch-'0');ch=gc;}if(neg)val=-val;return 1;}HP IL bool read(H& h, T&... t){return read(h)&&read(t...);}IL bool read(char &c){c=gc;return c!=EOF;}IL bool read(char *s){return scanf("%s",s);}
IL int rand(int a,int b){return uniform_int_distribution<int>(a,b)(rng);}IL ll randLL(ll a,ll b){return uniform_int_distribution<ll>(a,b)(rng64);}IL void inRand(int *a,int n,int l,int r){fr(i,0,n)a[i]=rand(l,r);}IL void inRandLL(ll *a,int n,ll l,ll r){fr(i,0,n)a[i]=randLL(l,r);}IL void inRand(vi &a,int n,int l,int r){fr(i,0,n)a[i]=rand(l,r);}IL void inRandLL(vl &a,int n,ll l,ll r){fr(i,0,n)a[i]=randLL(l, r);}
TP IL T lcm(T a,T b){return (a/gcd(a,b))*b;}TP IL T gcd(T a,T b){return b?gcd(b,a%b):a;}TP IL T power(T v,T p){T r=1;while(p>0){if(p & 0x1)r=(r*v);v=(v*v);p>>=1;}return r;}TP IL T power(T v,T p,T m){v%=m;T r=1;while(p>0){if(p & 0x1)r=(r*1LL*v)%m;v=(v*1LL*v)%m;p>>=1;}return r;}TP IL T powerL(T v,T p,T m){v%=m;T r=1;while(p>0){if(p & 0x1)r=MulL(r,v,m);v=MulL(v,v,m);p>>=1;}return r;}TP IL T MulL(T a, T b, T m){T r=0;a%=m;b%=m;while(b){if(b & 0x1)r=(r+a)%m;b>>=1;if(a<m-a)a<<=1;else a-=(m-a);}return r;}



Compiler output:
a.cc:27:14: fatal error: dbg.hpp: No such file or directory
   27 |     #include "dbg.hpp"
      |              ^~~~~~~~~
compilation terminated.