CodeEff/ECCO huggingface dataset:
# Original solution
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 998244353
eps = 10**-7
def inp(): return int(eval(input()))
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

K,N = inpl()
MAX = K+N+10
fac = [1]*(MAX+1)
for i in range(1,MAX+1):
	fac[i] = (fac[i-1]*i)%mod

gyakugen = [1]*(MAX+1)
gyakugen[MAX] = pow(fac[MAX],mod-2,mod)
for i in range(MAX,0,-1):
	gyakugen[i-1] = (gyakugen[i]*i)%mod

def Comb(n,k):#nCk
	return (fac[n]*gyakugen[k]*gyakugen[n-k])%mod

#K=k,N=n,0pair = 0
def calc(k,n,i):
	#i=2に帰着させる
	pairs = (i-2)//2
	k -= pairs
	n -= pairs

	#色々と例外処理
	if n < 0 or k <= 0:
		return 0
	elif k == 1 and n >= 2:
		return 0

	if n == 0: 	 #球が0個なら1通り
		ans = 1
	else:
		ans = 0
		#i=2の時の数え上げ
		for x in range(2):
			ball = n-x	#球
			box = k-1	#箱
			ans += Comb(box-1+ball,ball)%mod

	ans *= pow(2,pairs,mod)	#0pairの選び方
	return ans % mod

ans = []
for i in range(2,K+2):
	if i%2 == 0:
		pairs = (i-2)//2
		tmp = 0
		for p0 in range(pairs+1): #p0 = 0pairの数
			tmp1 = calc(K-p0*2 , N , i-p0*2) %mod #k-p0*2,i-p0*2で0pairが0組
			tmp2 = Comb(pairs,p0) %mod #0pairの選び方
			tmp += tmp1 * tmp2
			tmp %= mod
	ans.append(tmp)
	print(tmp)

ans = ans[::-1]
for i in range(1,K):
	print((ans[i]))


# Optimized solution
K,N = list(map(int, input().split()))
MAX = K+N+3
mod = 998244353

fac = [1]*(MAX+1)
for i in range(1,MAX+1):
	fac[i] = (fac[i-1]*i)%mod

rev_m = [1]*(MAX+1)
rev_m[MAX] = pow(fac[MAX],mod-2,mod)
for i in range(MAX,0,-1):
	rev_m[i-1] = (rev_m[i]*i)%mod

def Comb(n,k):#nCk
	return (fac[n]*rev_m[k]*rev_m[n-k])%mod


def f(n,k,i):
	if i == 2:
		if n < 0 or (k==1 and n>=2): #例外処理
			return 0

		if n == 0:
			ans = 1
		else:
			ans = Comb(k-2+n,n) + Comb(k-2+n-1,n-1)
		return ans % mod
	else: #i>2
		Sp = i//2-1
		ans = 0
		for p in range(Sp+1):
			ans += g(n,k,i,p)
		return ans % mod

def g(n,k,i,p):
	Sp = i//2-1
	if p == 0:
		return f(n-Sp,k-Sp,2) * pow(2,Sp,mod) % mod
	else: #p>0
		return g(n,k-2*p,i-2*p,0) * Comb(Sp,p)

ans = []
for i in range(2,K+2):
	if i%2 == 0:
		tmp = f(N,K,i)
	ans.append(tmp)
	print(tmp)

ans = ans[::-1]
for i in range(1,K):
	print((ans[i]))
# Original solution
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(eval(input()))

def reads():
  return [int(x) for x in input().split()]

K, N = reads()
MOD = 998244353

MAXN = 5000

fact = [1] * MAXN
for i in range(1, MAXN): fact[i] = (fact[i-1] * i) % MOD
invfact = [0] * MAXN; invfact[-1] = pow(fact[-1], MOD-2, MOD)
for i in range(MAXN-2, -1, -1): invfact[i] = invfact[i+1] * (i+1) % MOD
def comb(n, k):
  return fact[n] * invfact[n-k] * invfact[k] % MOD if 0 <= k <= n else 0
def h(n, k):
  return comb(n+k-1, n) if k >= 1 else 0

def solve(n, k, u):
  ans = 0
  for q in range(u+1):
    s = 2**(u-q) * h(n-u+q, k-q-u)
    # print(n, k, u, q, s)
    ans = (ans + comb(u, q) * pow(2, u-q, MOD) % MOD * h(n-u+q, k-q-u)) % MOD
  return ans

for i in range(2, 2*K+1):
  u = sum(j < i-j <= K for j in range(1, K+1))
  if i % 2 == 1:
    ans = solve(N, K, u)
  else:
    ans = (solve(N, K-1, u) + solve(N-1, K-1, u)) % MOD
  print(ans)

# Optimized solution
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(eval(input()))

def reads():
  return [int(x) for x in input().split()]

K, N = reads()
MOD = 998244353

MAXN = 4020

fact = [1] * MAXN
for i in range(1, MAXN): fact[i] = (fact[i-1] * i) % MOD
invfact = [0] * MAXN; invfact[-1] = pow(fact[-1], MOD-2, MOD)
for i in range(MAXN-2, -1, -1): invfact[i] = invfact[i+1] * (i+1) % MOD
def comb(n, k):
  return fact[n] * invfact[n-k] * invfact[k] % MOD if 0 <= k <= n else 0
def h(n, k):
  return comb(n+k-1, n)

def solve(n, k, u):
  ans = 0
  for q in range(u+1):
    ans = (ans + comb(u, q) * pow(2, u-q, MOD) % MOD * h(n-u+q, k-q-u)) % MOD
  return ans

anss = [0] * (2*K+1)
for i in range(2, K+2):
  u = sum(j < i-j <= K for j in range(1, K+1))
  if i % 2 == 1:
    ans = solve(N, K, u)
  else:
    ans = (solve(N, K-1, u) + solve(N-1, K-1, u)) % MOD
  anss[i] = ans
  print(ans)

for j in range(K+2, 2*K+1):
  print((anss[2*K - j + 2]))
# Original solution
k,n =list(map(int,input().split()))
mod = 998244353
fact=[1]*5000
for i in range(1,len(fact)):
  fact[i] = fact[i-1]*i%mod
def comb(n,k,p):
  if com[n][k] != -1:
    return com[n][k]
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=fact[n]
  b=fact[k]
  c=fact[n-k]
  yey = (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
  com[n][k] = yey
  return yey
def power_func(a,b,p):
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p
com = [[-1] *4050 for i in range(4050)]
for i in range(2,2*k+1):
  ans = 0
  if i %2 == 1:
    pp = (i+1)//2
    pm = i - pp
    p = min(k-pp+1,pm)
    for q in range(p+1):
      sen = comb(p,q,mod)*power_func(2,q,mod)%mod
      if n - q<0:
        continue
      r = k-p*2
      if r <0:
        r = 0
      ans += sen* comb(n+r-1,n-q,mod)%mod
    print((ans%mod))
  else:
    pp = i//2 +1
    pm = i//2 -1
    p = min(k-pp+1,pm)
    for q in range(p+1):
      sen = comb(p,q,mod)*power_func(2,q,mod)%mod
      if n - q<0:
        continue
      r = k-p*2-1
      if r <0:
        r = 0
      ans += sen* comb(n+r-1,n-q,mod)%mod
    for q in range(p+1):
      sen = comb(p,q,mod)*power_func(2,q,mod)%mod
      if n - q-1<0:
        continue
      r = k-p*2-1
      if r <0:
        r = 0
      ans += sen* comb(n+r-2,n-q-1,mod)%mod
    print((ans%mod))

# Optimized solution
k,n =list(map(int,input().split()))
mod = 998244353
fact = [1]*(n+k+1)
rfact = [1]*(n+k+1)
for i in range(n+k):
    fact[i+1] = rr = ((i+1) * fact[i]) % mod
    rfact[i+1] = pow(rr, mod-2, mod)
def comb(N, K,mod):
    return fact[N] * rfact[K] * rfact[N-K] % mod
kota = []
for i in range(2,k+2):
  ans = 0
  if i %2 == 1:
    pp = (i+1)//2
    pm = i - pp
    p = min(k-pp+1,pm)
    for q in range(p+1):
      sen = comb(p,q,mod)*pow(2,q,mod)%mod
      if n - q<0:
        break
      r = k-p*2
      if r <0:
        r = 0
      if n+r-1 < n-q:
        continue
      ans += sen* comb(n+r-1,n-q,mod)%mod
    kota.append(ans%mod)
  else:
    pp = i//2 +1
    pm = i//2 -1
    p = min(k-pp+1,pm)
    for q in range(p+1):
      sen = comb(p,q,mod)*pow(2,q,mod)%mod
      if n - q<0:
        break
      r = k-p*2-1
      if r <0:
        r = 0
      if n+r-1 < n-q:
        continue
      ans += sen* comb(n+r-1,n-q,mod)%mod
    for q in range(p+1):
      sen = comb(p,q,mod)*pow(2,q,mod)%mod
      if n - q-1<0:
        break
      r = k-p*2-1
      if r <0:
        r = 0
      if n+r-2 < n-q-1:
        continue
      ans += sen* comb(n+r-2,n-q-1,mod)%mod
    kota.append(ans%mod)
for i in kota:
  print(i)
for i in range(len(kota)-2,-1,-1):
  print((kota[i]))
# Original solution
K, N = list(map(int, input().split()))
mod = 998244353
A = []
p = mod - 2
while p != 0:
  A = [p%2] + A[:]
  p //= 2
def inved(x):
  y = 1
  for _ in range(len(A)):
    if A[_] == 1:
      y *= x
      y %= mod
    if _ != len(A) - 1:
      y *= y
      y %= mod
  return y

X = [0 for i in range(2*K-1)]
frac = [1]
for i in range(N + K):
  frac.append(((i+1)*frac[i])%mod)
invf = []
for i in range(N + K + 1):
  invf.append(inved(frac[i]))
for k in range(2, K+2):
  S = 0
  sign = 1
  l = k // 2
  for m in range(min(l+1, N//2+1)):
    prod = (sign * (frac[l]*frac[N+K-2*m-1])) % mod
    prod *= (invf[m]*invf[l-m]) % mod
    prod %= mod
    prod *= (invf[N-2*m] * invf[K-1]) % mod
    prod %= mod
    S += prod
    S %= mod
    sign *= -1
  X[k-2], X[2*K-k] = S, S
for i in range(2*K-1):
  print((X[i]))

# Optimized solution
K, N = list(map(int, input().split()))
mod = 998244353
def inved(a):
  x, y, u, v, k, l = 1, 0, 0, 1, a, mod
  while l != 0:
    x, y, u, v = u, v, x - u * (k // l), y - v * (k // l)
    k, l = l, k % l
  return x % mod

X = [0 for i in range(2*K-1)]
frac = [1]
for i in range(N + K):
  frac.append(((i+1)*frac[i])%mod)
invf = []
for i in range(N + K + 1):
  invf.append(inved(frac[i]))
for k in range(2, K+2):
  S = 0
  sign = 1
  l = k // 2
  for m in range(min(l+1, N//2+1)):
    prod = (sign * (frac[l]*frac[N+K-2*m-1])) % mod
    prod *= (invf[m]*invf[l-m]) % mod
    prod %= mod
    prod *= (invf[N-2*m] * invf[K-1]) % mod
    prod %= mod
    S += prod
    S %= mod
    sign *= -1
  X[k-2], X[2*K-k] = S, S
for i in range(2*K-1):
  print((X[i]))
# Original solution
from itertools import combinations

n = int(eval(input()))
r = list(range(n))
a = [(set(), set()) for _ in r]
for i in r:
  for _ in range(int(eval(input()))):
    x, y = list(map(int, input().split()))
    a[i][y].add(x - 1)

fail = lambda x: not all(a[i][0].isdisjoint(x) and a[i][1].issubset(x) for i in x)

while all(map(fail, combinations(r, n))):
  n -= 1
print(n)


# Optimized solution
from itertools import combinations

n = int(eval(input()))
r = list(range(n))
a = [(set(), set()) for _ in r]
for i in r:
  for _ in range(int(eval(input()))):
    x, y = list(map(int, input().split()))
    a[i][y].add(x - 1)

fail = lambda x: not all(a[i][0].isdisjoint(x) and a[i][1] < x for i in x)

while all(map(fail, list(map(set, combinations(r, n))))):
  n -= 1
print(n)
# Original solution
from itertools import combinations

n = int(eval(input()))
r = list(range(n))
a = [([], []) for _ in r]
for i in r:
  for _ in range(int(eval(input()))):
    x, y = list(map(int, input().split()))
    a[i][y].append(x - 1)

fail = lambda x: not all(x.isdisjoint(a[i][0]) and x.issuperset(a[i][1]) for i in x)

while all(map(fail, list(map(set, combinations(r, n))))):
  n -= 1
print(n)


# Optimized solution
from itertools import combinations
 
n = int(eval(input()))
r = list(range(n))
a = [(set(), set()) for _ in r]
for i in r:
  for _ in range(int(eval(input()))):
    x, y = list(map(int, input().split()))
    a[i][y].add(x - 1)
 
fail = lambda x: not all(a[i][0].isdisjoint(x) and a[i][1] < x for i in x)
 
while all(map(fail, list(map(set, combinations(r, n))))):
  n -= 1
print(n)
# Original solution
def popcount(x):
  r = 0
  while x:
    r += 1
    x &= x - 1
  return r
 
n = int(eval(input()))
r = list(range(n))
a = [[0, 0] for _ in r]
for i in r:
  for _ in range(int(eval(input()))):
    x, y = list(map(int, input().split()))
    a[i][y] |= 1 << (x - 1)
 
m = 0
l = (1 << n) - 1
for x in range(1, l + 1):
  if all(a[i][0] & x == a[i][1] & l - x == 0 for i in r if x >> i & 1):
    m = max(m, popcount(x))
print(m)


# Optimized solution
def popcount(x):
  r, q = 0, x
  while x:
    r += 1
    x &= x - 1
  return r, q
 
n = int(eval(input()))
r = list(range(n))
a = [[0, 0] for _ in r]
for i in r:
  for _ in range(int(eval(input()))):
    x, y = list(map(int, input().split()))
    a[i][y] |= 1 << (x - 1)
l = (1 << n) - 1 
b = sorted(map(popcount, list(range(1, l + 1))))
ans = next((i for i, x in reversed(b)
           if all(a[j][0] & x == a[j][1] & l - x == 0 for j in r if x >> j & 1)), 0)
print(ans)
# Original solution
def popcount(x):
  r, q = 0, x
  while x:
    r += 1
    x &= x - 1
  return r, q
 
n = int(eval(input()))
r = list(range(n))
a = [[0, 0] for _ in r]
for i in r:
  for _ in range(int(eval(input()))):
    x, y = list(map(int, input().split()))
    a[i][y] |= 1 << (x - 1)
l = (1 << n) - 1 
b = sorted(map(popcount, list(range(1, l + 1))))
ans = next((i for i, x in reversed(b)
           if all(a[j][0] & x == a[j][1] & l - x == 0 for j in r if x >> j & 1)), 0)
print(ans)


# Optimized solution
from itertools import combinations, count
 
n = int(eval(input()))
r = list(range(n))
a = [(set(), set()) for _ in r]
for i in r:
  for _ in range(int(eval(input()))):
    x, y = list(map(int, input().split()))
    a[i][y].add(x - 1)
r = next(i for i in count(n, - 1) for x in map(set, combinations(r, i))
         if all(a[j][0].isdisjoint(x) and a[j][1] < x for j in x))
print(r)
# Original solution
from itertools import combinations, count
 
n = int(eval(input()))
r = list(range(n))
a = [(set(), set()) for _ in r]
for i in r:
  for _ in range(int(eval(input()))):
    x, y = list(map(int, input().split()))
    a[i][y].add(x - 1)
r = next(i for i in count(n, -1) for x in map(set, combinations(r, i))
         if all(a[j][0].isdisjoint(x) and a[j][1].issubset(x) for j in x))
print(r)


# Optimized solution
from itertools import combinations, count
 
n = int(eval(input()))
r = list(range(n))
a = [(set(), set()) for _ in r]
for i in r:
  for _ in range(int(eval(input()))):
    x, y = list(map(int, input().split()))
    a[i][y].add(x - 1)
r = next(i for i in count(n, -1) for x in map(set, combinations(r, i))
         if all(a[j][0].isdisjoint(x) and a[j][1] < x for j in x))
print(r)
# Original solution
import sys
from pprint import pprint

def solve(n, info):
    ans = 0
    for i in range(2 ** n):
        true_info = {}
        p_info = [0] * n
        for j in range(n):
            if (i >> j) & 1:
                true_info[j] = info[j]
                for x, y in info[j]:
                    if y == 1:
                        true_info[x-1] = info[x-1]
                # pprint(info[j])
                p_info[j] = 1
        # print("p_info")
        # pprint(p_info)
        # print("true_info")
        # pprint(true_info)
        flag = True
        for _, info_list in list(true_info.items()):
            for x, y in info_list:
                if p_info[x-1] != y:
                    flag = False
                    break
            if not flag:
                break

        if flag:
            # pprint(true_info)
            ans = max(ans, sum(p_info))

    print(ans)

if __name__ == '__main__':
    n = int(sys.stdin.readline().strip())
    info = []
    for i in range(n):
        a = int(sys.stdin.readline().strip())
        info.append([])
        for _ in range(a):
            x, y = list(map(int, sys.stdin.readline().strip().split(" ")))
            info[i].append((x, y))
    
    # pprint(info)
    solve(n, info)

# Optimized solution
import sys
from pprint import pprint

def solve(n, info):
    ans = 0
    for i in range(2 ** n):
        true_info = {}
        p_info = [0] * n
        for j in range(n):
            if (i >> j) & 1:
                true_info[j] = info[j]
                # pprint(info[j])
                p_info[j] = 1
        # print("p_info")
        # pprint(p_info)
        # print("true_info")
        # pprint(true_info)
        flag = True
        for _, info_list in list(true_info.items()):
            for x, y in info_list:
                if p_info[x-1] != y:
                    flag = False
                    break
            if not flag:
                break

        if flag:
            # pprint(true_info)
            ans = max(ans, sum(p_info))

    print(ans)

if __name__ == '__main__':
    n = int(sys.stdin.readline().strip())
    info = []
    for i in range(n):
        a = int(sys.stdin.readline().strip())
        info.append([])
        for _ in range(a):
            x, y = list(map(int, sys.stdin.readline().strip().split(" ")))
            info[i].append((x, y))
    
    # pprint(info)
    solve(n, info)
# Original solution
n=int(eval(input()))
X=[]*n
A=[]*n

for i in range(n):
	a=int(eval(input()))
	A.append(a)
	xy = [list(map(int,input().split())) for _ in range(a)]
	X.append(xy)

ans=0
for i in range(2**n):
	cnt=0
	for j in range(n):
		if (i>>j)&1:
			for k,l in X[j]:
				if not ((i>>(k-1))&1)==l:
					cnt=1
					break

	if cnt==0:
		ans = max(ans,bin(i).count("1"))

print(ans)

# Optimized solution
n=int(eval(input()))
X=[]*n

for i in range(n):
	a=int(eval(input()))
	xy = [list(map(int,input().split())) for _ in range(a)]
	X.append(xy)

ans=0
for i in range(2**n):
	cnt=0
	for j in range(n):
		if (i>>j)&1:
			for k,l in X[j]:
				if not ((i>>(k-1))&1)==l:
					cnt=1
					break

	if cnt==0:
		ans = max(ans,bin(i).count("1"))

print(ans)
# Original solution
import sys
sys.setrecursionlimit(10**7)

N = int(eval(input()))

claim = []

for _ in range(N):
    memo = []
    A = int(eval(input()))
    for _ in range(A):
        x, y = input().split()
        memo.append((x,y))
    claim.append(memo)

maximam = 0
for i in range(2**N):
    flag = True
    bin_i = (N - len(str(bin(i))[2:]))*["0"] + list(bin(i))[2:]
    for j, man in enumerate(bin_i):
        if man == "0":
            continue
        for x, y in claim[j]:
            if bin_i[int(x)-1] != y:
                flag = False
    if flag:
        count = 0
        for b in bin_i:
            if b=="1":
                count+=1
        maximam = max(maximam,count)
print(count)

# Optimized solution
import sys
sys.setrecursionlimit(10**7)

N = int(eval(input()))

claim = []

for _ in range(N):
    memo = []
    A = int(eval(input()))
    for _ in range(A):
        x, y = list(map(int, input().split()))
        memo.append((x,y))
    claim.append(memo)

maximam = 0
for bit in range(2**N):
    flag = True
    count = 0
    for i in range(N):
        if bit & (1<<i):
            count+=1
            for x, y in claim[i]:
                if (bit & (1<<(x-1)) and y==0) or (not (bit & (1<<(x-1))) and y==1):
                    flag = False
    if flag:
        maximam = max(maximam,count)
print(maximam)
# Original solution
import itertools
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
xy = []
for _ in range(n):
    m = int(readline())
    tmp = [list(map(int, readline().split())) for _ in range(m)]
    xy.append(tmp)

ans = 0

for l in list(itertools.product([0, 1], repeat=n)):
    bl = True
    for i,a in enumerate(l):
        if a == 1:
            for b in xy[i]:
                if l[b[0] - 1] != b[1]:
                    bl = False
    if bl:
        ans = max(ans, sum(l))
print(ans)

# Optimized solution
import itertools
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
xy = []
for _ in range(n):
    m = int(readline())
    tmp = [list(map(int, readline().split())) for _ in range(m)]
    xy.append(tmp)
    
# 逆から
for l in sorted(itertools.product([0, 1], repeat=n),reverse=True):
    bl = True
    for i, a in enumerate(l):
        if a == 1:
            for b in xy[i]:
                if l[b[0] - 1] != b[1]:
                    bl = False
                    break
    if bl:
        print((sum(l)))
        exit()
print('0')
# Original solution
N = int(eval(input()))
A = []
XY = []
honest_count = []

for i in range (N):
    a = int(eval(input()))
    A.append(a)
    inter = []
    for x in range(a):
        xy = list(map(int, input().split()))
        inter.append(xy)
    XY.append(inter)

for i in range(2 ** N):
    pt = [0] * N
    ck = 1
    for j in range(N):
        if (i >> j) & 1:
            pt[N - j - 1] = 1

    for k in range(N): # k人目が正直者の場合チェック
        if pt[k] == 1:
            for l in range(A[k]):
                if XY[k][l][1] != pt[XY[k][l][0] - 1]:
                    ck = 0
    if ck == 1:
        honest_count.append(sum(pt))


print((max(honest_count)))

# Optimized solution
import itertools
n = int(eval(input()))
l = []
for i in range(n):
    d = int(eval(input()))
    for dd in range(d):
        x, y = list(map(int, input().split()))
        l.append([i, x-1, y])

ans = 0
for p in itertools.product([0, 1], repeat=n):
    for ll in l:
        if p[ll[0]] == 1 and p[ll[1]] != ll[2]:
            break
    else:
        ans = max(ans, sum(p))
print(ans)
# Original solution
import sys
input = sys.stdin.readline
n = int(eval(input()))
chk = [[set(),set()] for _ in range(n)]
for o in range(n):
  a = int(eval(input()))
  for i in range(a):
    x,y = [int(i) for i in input().split()]
    if y == 0:
      chk[o][0].add(x-1)
    if y == 1:
      chk[o][1].add(x-1)
    
chk = tuple(chk)
answer = 0
for i in range(2**n):
  b = format(i,'b')
  b = b.zfill(n)[::-1]
  chk_0 = set()
  chk_1 = set()
  p = []
  for j in range(n):
    if b[j] == '1':
      p.append(j)
      chk_1.add(j)
    if b[j] == '0':
      chk_0.add(j)
  for i in p:
    if not chk[i][0] <= chk_0:
      break
    if not chk[i][1] <= chk_1:
      break
    if i == p[len(p)-1]:
      answer = max(answer,len(p))
      
print(answer)

# Optimized solution
n = int(eval(input()))
a = []
xy = []
for i in range(n):
    a += [int(eval(input()))]
    xy += [[list(map(int,input().split())) for i in range(a[i])]]
honest = []
for i in range(2 ** n):
    flag = 0
    for j in range(n):
        if (i >> j)&1 == 1: #j番目は正直であるとき
            for person_state in xy[j]:
              if (i >> (person_state[0]-1) & 1) != person_state[1]:
                  flag = 1 #矛盾が生じるとflagを立てる
                  break
    if flag == 0:
        honest += [bin(i)[2:].count("1")]
print((max(honest)))
# Original solution
import sys
input = sys.stdin.readline


def main():
    N = int(eval(input()))
    A = [[set(), set()] for _ in range(N)]
    for i in range(N):
        m = int(eval(input()))
        for j in range(m):
            x, y = list(map(int, input().split()))
            A[i][y].add(x)

    ans = 0
    for i in range(1 << N):
        h = set()
        u = set()
        for j in range(N):
            if (i >> j) & 1:
                h.add(j+1)
            else:
                u.add(j+1)
        b = True
        for k in list(h):
            k -= 1
            h |= A[k][1]
            u |= A[k][0]
            if h & u:
                b = False
        if b:
            ans = max(ans, bin(i).count("1"))
    print(ans)


if __name__ == '__main__':
    main()


# Optimized solution
import sys
input = sys.stdin.readline


def main():
    N = int(eval(input()))
    A = [[set(), set()] for _ in range(N)]
    for i in range(N):
        m = int(eval(input()))
        for j in range(m):
            x, y = list(map(int, input().split()))
            A[i][y].add(x)

    ans = 0
    for i in range(1 << N):
        h = set()
        u = set()
        for j in range(N):
            if (i >> j) & 1:
                h.add(j+1)
            else:
                u.add(j+1)
        b = True
        for k in list(h):
            k -= 1
            h |= A[k][1]
            u |= A[k][0]
            if h & u:
                b = False
                break
        if b:
            ans = max(ans, bin(i).count("1"))
    print(ans)


if __name__ == '__main__':
    main()
# Original solution
import sys
input = sys.stdin.readline


def main():
    N = int(eval(input()))
    A = [[set(), set()] for _ in range(N)]
    for i in range(N):
        m = int(eval(input()))
        for j in range(m):
            x, y = list(map(int, input().split()))
            A[i][y].add(x)

    ans = 0
    for i in range(1 << N):
        h, u = set(), set()
        for j in range(N):
            if (i >> j) & 1:
                h.add(j+1)
            else:
                u.add(j+1)
        for k in list(h):
            h |= A[k-1][1]
            u |= A[k-1][0]
        if not (h & u):
            ans = max(ans, bin(i).count("1"))
    print(ans)


if __name__ == '__main__':
    main()


# Optimized solution
import sys
input = sys.stdin.readline


def main():
    N = int(eval(input()))
    A = [[set(), set()] for _ in range(N)]
    for i in range(N):
        m = int(eval(input()))
        for j in range(m):
            x, y = list(map(int, input().split()))
            A[i][y].add(x)

    ans = 0
    for i in range(1 << N):
        h, u = set(), set()
        for j in range(N):
            if (i >> j) & 1:
                h.add(j+1)
                h |= A[j][1]
                u |= A[j][0]
            else:
                u.add(j+1)
        if not (h & u):
            ans = max(ans, bin(i).count("1"))
    print(ans)


if __name__ == '__main__':
    main()