void main()
{
    long n = readln.chomp.to!long;
    long[] a = new long[n];
    long[][] x = new long[][](n), y = new long[][](n);
    foreach (i; 0 .. n)
    {
        a[i] = readln.chomp.to!long;
        foreach (j; 0 .. a[i])
        {
            long[] tmp = readln.split.to!(long[]);
            x[i] ~= tmp[0] - 1, y[i] ~= tmp[1];
        }
    }

    long result;
    foreach (i; 0 .. (1 << n))
    {
        bool ok = true;
        foreach (j; 0 .. n)
        {
            if (!((1 << j) & i)) continue;

            foreach (k; 0 .. a[j])
            {
                if (((i >> x[j][k]) & 1) ^ y[j][k]) ok = false;
            }
        }

        if (ok) result = max(result, popcnt(i));
    }

    result.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;