Harryxun/stf_run huggingface dataset:
n, k = map(int, input().split())
D = set(map(int, input().split()))
for ans in range(n,9999):
    for c in str(ans):
        if int(c) in D:
            break
    else:
        print(ans)
        break

### FIXED CODE ###

a = input().split()

if a.count('5') == 2 and a.count('7') == 1:
    print('YES')
else:
    print('NO')
mod=10**9+7
n,k=map(int,input().split())
arr=list(map(int,input().split()))
arr=sorted(arr,reverse=True,key=lambda x:abs(x)) #絶対値の順にソートする
if k==n: #k=nのときはすべてを掛け合わせるほかない
  ans=1
  for i in range(n):
    ans*=arr[i]
    ans%=mod
  print(ans)
else:
  if k%2==1 and max(arr)<0: #答えが負になる場合は絶対値の小さい順にK個掛け合わせる
    ans=1
    for i in range(k):
      ans*=arr[n-1-i]
      ans%=mod
      print(ans)
  else:
    ans=1
    cnt=0
    for i in range(k): #絶対値の大きい順にK個掛け合わせる
      if arr[i]<0: #負数を掛けた回数を数えておく
        cnt+=1
      ans*=arr[i]
      ans%=mod
    if cnt%2==0: #負数を偶数回掛けていれば答えは非負なのでそのまま出力
      print(ans)
    else: #そうでなければ調整を行う
      min_plus=-1
      min_minus=1
      for i in range(k): #絶対値の大きい順にK個を見て最小の非負の数・負の数を探す
        if arr[i]>=0:
          min_plus=arr[i]
        else:
          min_minus=arr[i]
      max_plus=-1
      max_minus=1
      for i in range(k,n): #残るN-K個を見て最大の非負の数・負の数を探す
        if arr[i]>=0 and max_plus==-1:
          max_plus=arr[i]
        if arr[i]<0 and max_minus==1:
          max_minus=arr[i]
      if min_plus==-1: #もし最小の非負の数がなければ、最小の負の数を取り除くしかない
        arr.remove(min_minus)
        ans=1
        for i in range(k-1):
          ans*=arr[i]
          ans%=mod
        ans*=max_plus
        ans%=mod
      elif min_minus==1: #もし最小の負の数がなければ、最小の非負の数を取り除くしかない
        arr.remove(min_plus)
        ans=1
        for i in range(k-1):
          ans*=arr[i]
          ans%=mod
        ans*=max_minus
        ans%=mod
      elif min_plus*max_plus>=min_minus*max_minus: #そうでなければより倍率の大きいほうを選ぶ
        arr.remove(min_minus)
        ans=1
        for i in range(k-1):
          ans*=arr[i]
          ans%=mod
        ans*=max_plus
        ans%=mod
      else:
        arr.remove(min_plus)
        ans=1
        for i in range(k-1):
          ans*=arr[i]
          ans%=mod
        ans*=max_minus
        ans%=mod
      print(ans)

### FIXED CODE ###

N=int(input())

if N%1000==0:
    print(0)
else:
    print(-(N%1000)+1000)
x = input()

Pow = x*x*x

print (Pow)

### FIXED CODE ###

# -*- coding: utf-8 -*-

x = int(input())

print(x*x*x)
n, k = map(int, input().split())
A = list(map(int, input().split()))
L = [1]
def f(L):
    if A[L[-1]-1] not in L:
        L.append(A[L[-1]-1])
        return f(L)
    else:
        return L
P = f(L)
a = A[P[-1]-1]
j = P.index(a)
r = len(P)
l = r - j
if k+1 <= r:
  print(P[k])
else:
  print(P[j + (k-j)%l])
  


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

n, k = map(int, input().split())
A = list(map(int, input().split()))
L = [1]
S = {1}

def f(L, S):
    last = L[-1]-1
    if A[last] not in S:
        L.append(A[last])
        S |= {A[last]}
        return f(L, S)
    else:
        return L
P = f(L, S)
a = A[P[-1]-1]
j = P.index(a)
r = len(P)
l = r - j

if k+1 <= j:
    print(P[k])
else:
    print(P[j+(k-j)%l])
import sys
S = input()
T = "AKIHABARA"
posS = 0
posT = 0
while True:
    if posS == len(S) and posT >= len(T)-1:
        print("YES")
        sys.exit()
    if posT >= len(T):
        print("NO")
        sys.exit()
    if S[posS] == T[posT]:
        posS += 1
        posT += 1
    elif T[posT] == 'A':
        posT += 1
    else:
        print("NO")
        sys.exit()

### FIXED CODE ###

import sys
S = input()
T = "AKIHABARA"
posS = 0
posT = 0
while True:
    if posS == len(S):
        if posT >= len(T)-1:
            print("YES")
        else:
            print("NO")
        sys.exit()
    if posT >= len(T):
        print("NO")
        sys.exit()
    if S[posS] == T[posT]:
        posS += 1
        posT += 1
    elif T[posT] == 'A':
        posT += 1
    else:
        print("NO")
        sys.exit()
N, M = map(int, input().split())
n = []
m = []
for i in range(N):
  s = str(input())
  row = []
  for j in range(N):
    if s[i] == "#":
      row.append(1)
    else:
      row.append(0)
  n.append(row)
for i in range(M):
  s = str(input())
  row = []
  for j in range(M):
    if s[i] == "#":
      row.append(1)
    else:
      row.append(0)
  m.append(row)

def search(a,b):
  for r in range(a, a+M):
    for c in range(b, b+M):
      if n[r][c] != m[r][c]:
        return False
  return True
  
ans = 0
for i in range(N-M):
  for j in range(N-M):
    if search(i,j):
      ans = 1
      break
  if ans:
    break
if ans:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

N, M = map(int, input().split())
n = []
m = []
for i in range(N):
  s = str(input())
  row = []
  for j in range(N):
    if s[j] == "#":
      row.append(1)
    else:
      row.append(0)
  n.append(row)
for i in range(M):
  s = str(input())
  row = []
  for j in range(M):
    if s[j] == "#":
      row.append(1)
    else:
      row.append(0)
  m.append(row)
 
def search(a,b):
  mr = mc = 0
  for r in range(a, a+M):
    for c in range(b, b+M):
      if n[r][c] != m[mr][mc]:
        return False
      mc += 1
    mr += 1
    mc = 0
  return True

ans = 0
for i in range(N-M+1):
  for j in range(N-M+1):
    if search(i,j):
      ans = 1
      break
  if ans:
    break
if ans:
  print("Yes")
else:
  print("No")
a = int(input())
b = int(input())
c = int(input())
x = [a, b, c]
y = []

for i in x:
  if(i not in y):
    y.append(i)
print(len(y))


### FIXED CODE ###

j = (input())

x = j.split()
y = []

for i in x:
  if(i not in y):
    y.append(i)
print(len(y))
%%time
def saiki(now, reachable):
#     print(now)
    cand = copy.deepcopy(dic[now])
    cue = []
    cand = dic[now]
    while len(cand) > 0:
        c = cand[0]
        cand.pop(0)
        
#         print(cand)
        if c in reachable:
            pass
        else:
            reachable += [c]
            cand += saiki(c, reachable)
            
    return reachable

def saiki_check(now, reachable, reachable_check_target):
#     print(now)
    cue = []
    cand = copy.deepcopy(dic[now])
    ans = False
    while len(cand) > 0:
        c = cand[0]
        cand.pop(0)
        
#         print(cand)
        if c in reachable:
            pass
        else:
            reachable += [c]
            if c == reachable_check_target:
                ans = True
                break
            out = saiki_check(c, reachable, reachable_check_target)
            cand = cand + out[0]
            ans = out[1]
            if ans:
                break
    return reachable, ans
import copy
anss = [0]
for k_start in range(1, m + 1):
    dic = {}
    for k in range(1, n+1):
        dic[k] = []
    for k in range(k_start, m):
        dic[a[k]] += [b[k]]
        dic[b[k]] += [a[k]]
    cutted = [a[k_start-1], b[k_start-1]]
    
#     print(dic)
    if saiki_check(cutted[0], [cutted[0]], cutted[1])[1]:
#     print(dic)
#     reachable = []
        s = anss[-1]
#         print('a')
    else:
        nodes = list(range(1,n+1))
        rs = []
        while len(nodes) > 0:
            reachable = saiki(nodes[0], [nodes[0]])
#             print(reachable)
            for r in reachable:
                nodes.remove(r)
            rs.append(len(reachable))
    #     print(rs)
        s = 0
        for c in combinations(rs, 2):
            s += c[0] * c[1]
        anss.append(s)
#     aaaaa
    print(s)
#     aaaaa

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline
 
N, M = map(int, input().split())
X = []
for _ in range(M):
    a, b = map(int, input().split())
    X.append((a-1, b-1))
X = X[::-1]
    
P = [-1] * N
CT = [1] * N
def pr(i):
    if P[i] < 0:
        return i
    t = pr(P[i])
    P[i] = t
    return t
 
ANS = [0] * M
ans = N * (N-1) // 2
ANS[-1] = ans
for m in range(M-1):
    a, b = X[m]
    pa = pr(a)
    pb = pr(b)
    
    if pa != pb:
        ans -= CT[pa] * CT[pb]
        P[pa] = pb
        CT[pb] += CT[pa]
 
    ANS[-m-2] = ans
 
for a in ANS:
    print(a)
S = input()
N = int(input())
N = int(N/2)
S1 = S[:N]
S2 = S[N:]

if S1 == S2:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

N = int(input())
S = input()

n = int(N/2)
s1 = S[:n]
s2 = S[n:]

if s1 == s2:
    print('Yes')
else:
    print('No')
a = input()
print(a**3)

### FIXED CODE ###

a = int(input())
print(a**3)
i = list(map(int,input().split()))
A = i[0]
B = i[1]
if A>12:
  pritn(B)
  elif A<6:
    print(0)
    else:
      print(B/2)
      

### FIXED CODE ###

A,B = map(int,input().split())
if A<6:
  print(0)
elif A<13:
  print(B//2)
else:
  print(B)
import math
from functools import reduce


def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


n = int(input())
a = [int(i) for i in input().split()]

ans1 = 0

lcm = lcm_list(a)

for num in a:
    ans1 += (lcm - 1) % num

print(ans1)


### FIXED CODE ###

import fractions
from functools import reduce
 
 
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
 
 
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
 
 
n = int(input())
a = [int(i) for i in input().split()]
 
ans1 = 0
 
lcm = lcm_list(a)
 
for num in a:
    ans1 += (lcm - 1) % num
 
print(ans1)
n=int(input(""))
ain=input("").split(" ")
a=[]
for i in range(n):
    a+=[int(ain[i])]
q=int(input(""))
c=[]
listb=[]
listc=[]
for i in range(q):
    c+=[input("").split(" ")]
    listb+=[int(c[i][0])]
    if (listb[i] in a):
        listc+=[int(c[i][1])]
        for k in range(n):
            if (a[k]==listb[i]):
                a[k]=listc[i]
    print(sum(a))
        

        


### FIXED CODE ###

n=int(input(""))
ain=input("").split(" ")
a={1:0,}
c=[]
for i in range(n):
    c+=[int(ain[i])]
s=sum(c)
for i in range(n):
    if (c[i] in a):
        a[c[i]]+=1
    else:
        a[c[i]]=1
q=int(input(""))
c=[]

for i in range(q):
    c=input("").split(" ")
    bb=int(c[0])
    cc=int(c[1])
    if (bb in a and a[bb]!=0):
        s+=(cc-bb)*a[bb]
        if (cc in a):
            a[cc]+=a[bb]
        else:
            a[cc]=a[bb]
        a[bb]=0
                              
    print(s)
N=int(input())
n=N%10
if n=2,4,5,7,9:
    print('hon')
elif n=0,1,6,8:
    print('pon')
else:
    print('bon')

### FIXED CODE ###

a = int(input())
a %= 10

if a==0 or a==1 or a==6 or a==8:
  print("pon")
elif a==3:
  print("bon")
else:
  print("hon")
C = input()
alphabet = {1:"a", 2:"b", 3:"d", 4:"d", 5:"e", 6:"f", 7:"g", 8:"h", 9:"i", 10:"j", 11:"k", 12:"l", 13:"m", 14:"n", 15:"o", 16:"p", 17:"q", 18:"r", 19:"s", 20:"t", 21:"u", 22:"v", 23:"w", 24:"x", 25:"y", 26:"z"}
keys = [k for k, v in alphabet.items() if v == C][0]
print(alphabet[int(keys) + 1])

### FIXED CODE ###

C = input()
alphabet = {1:"a", 2:"b", 3:"c", 4:"d", 5:"e", 6:"f", 7:"g", 8:"h", 9:"i", 10:"j", 11:"k", 12:"l", 13:"m", 14:"n", 15:"o", 16:"p", 17:"q", 18:"r", 19:"s", 20:"t", 21:"u", 22:"v", 23:"w", 24:"x", 25:"y", 26:"z"}
keys = [k for k, v in alphabet.items() if v == C][0]
print(alphabet[int(keys) + 1])
import sys
input = sys.stdin.readline
K = int(input())
S = list(input())[: -1]
mod = 10 ** 9 + 7

class Factorial:
  def __init__(self, n, mod):
    self.f = [1]
    for i in range(1, n + 1):
      self.f.append(self.f[-1] * i % mod)
    self.i = [pow(self.f[-1], mod - 2, mod)]
    for i in range(1, n + 1)[: : -1]:
      self.i.append(self.i[-1] * i % mod)
    self.i.reverse()
  def factorial(self, i):
    return self.f[i]
  def ifactorial(self, i):
    return self.i[i]
  def combi(self, n, k):
    return self.f[n] * self.i[n - k] % mod * self.i[k] % mod
###
f = Factorial(10 ** 5 * 3, mod)
res = 0
for i in range(K + 1):
  #i ko migi soto
  t = f.combi(len(S) - 1 + K - i, len(S) - 1) * pow(25, K - i, mod) % mod
  t = t * pow(26, i, mod) % mod
  res += t
  res %= mod
print(res)

### FIXED CODE ###

import sys
input = sys.stdin.readline
K = int(input())
S = list(input())[: -1]
mod = 10 ** 9 + 7

class Factorial:
  def __init__(self, n, mod):
    self.f = [1]
    for i in range(1, n + 1):
      self.f.append(self.f[-1] * i % mod)
    self.i = [pow(self.f[-1], mod - 2, mod)]
    for i in range(1, n + 1)[: : -1]:
      self.i.append(self.i[-1] * i % mod)
    self.i.reverse()
  def factorial(self, i):
    return self.f[i]
  def ifactorial(self, i):
    return self.i[i]
  def combi(self, n, k):
    return self.f[n] * self.i[n - k] % mod * self.i[k] % mod
###
f = Factorial(10 ** 6 * 3, mod)
res = 0
for i in range(K + 1):
  #i ko migi soto
  t = f.combi(len(S) - 1 + K - i, len(S) - 1) * pow(25, K - i, mod) % mod
  t = t * pow(26, i, mod) % mod
  res += t
  res %= mod
print(res)
N=int(input())
T = [int(input()) for _ in range(N)]

from functools import reduce
from fraction import gcd

def lcm(a,b):
  return a*b //gcd(a,b)

print(reduce(lcm, T))
  

### FIXED CODE ###

N=int(input())
T = [int(input()) for _ in range(N)]

from functools import reduce
from fractions import gcd

def lcm(a,b):
  return a*b //gcd(a,b)

print(reduce(lcm, T))
N, M = map(int, raw_input().split())
a = []
b = []
ikeru = [0]*(N+1)
for i in range(M):
    a_tmp, b_tmp = map(int, raw_input().split())
    a.append(a_tmp)
    b.append(b_tmp)

for i in range(M):
    if a[i] == 1:
        ikeru[b[i]] = 1
ikeru_2 = [0]*(N+1)
for i in range(M):
    if ikeru[a[i]] == 1:
        ikeru_2[b[i]] = 1
if ikeru_2[N] == 1 || ikeru[N] == 1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


### FIXED CODE ###

N, M = map(int, input().split())
a = []
b = []
ikeru = [0]*(N+1)
for i in range(M):
    a_tmp, b_tmp = map(int, input().split())
    a.append(a_tmp)
    b.append(b_tmp)

for i in range(M):
    if a[i] == 1:
        ikeru[b[i]] = 1
ikeru_2 = [0]*(N+1)
for i in range(M):
    if ikeru[a[i]] == 1:
        ikeru_2[b[i]] = 1
if ikeru_2[N] == 1 or ikeru[N] == 1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
N=int(input())
a = list(map(int,input().split()))
c=0
i=0
print(a)
while(c==0 and i<N):
    if(a[i]%2==0):
        if(a[i]%3==0 or a[i]%5==0):
            i+=1
        else:
            c+=1
    else:
        i+=1
if(c==0):
    print("APPROVED")
else:
    print("DENINED")


### FIXED CODE ###

A,B,C=input().split()
if(A==B):
    if(A!=C):
        print("Yes")
    else:
        print("No")
else:
    if(B==C):
        print("Yes")
    else:
        if(A==C):
            print("Yes")
        else:
            print("No")
from itertools as f;from fractions import*;c=lambda l:list(f.accumulate([0]+l,gcd));_,a=open(0);*a,=map(int,a.split());print(max(gcd(s,t)for s,t in zip(c(a),c(a[::-1])[-2::-1])))

### FIXED CODE ###

#!/usr/bin/env python3
from itertools import*
from fractions import*
ac = lambda l: list(accumulate([0] + l, gcd))
n, *a = map(int, open(0).read().split())
print(max(gcd(s, t) for s, t in zip(ac(a), ac(a[::-1])[::-1][1:])))
N = int(input())
H = int(input())
W = int(input())
n = 0
cnt = 0
while n<N:
    A = int(input())
    B = int(input())
    n +=1
    if (H == A and W == B) or (H == A/2 and W == B/2):
        cnt = +1
print(cnt)

### FIXED CODE ###

n = str(input())
print(n.count('2'))
N = int(input())
P = []

for _ in range(N):
    P.append(list(map(int, input().split())))

dp = [[0 for _ in range(3)] for _ in range(1000)]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if k == j:
                continue
            dp[i][k] = max(dp[i][k], dp[i-1][j] + P[i][k])
            
print(max(dp[N-1]))

### FIXED CODE ###

N = int(input())
P = []

for _ in range(N):
    P.append(list(map(int, input().split())))

dp = [[0 for _ in range(3)] for _ in range(10**5)]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if k == j:
                continue
            dp[i][k] = max(dp[i][k], dp[i-1][j] + P[i][k])
            
print(max(dp[N-1]))
from collections import defaultdict
from math import gcd

N = int(input())
X = [list(map(int, input().split())) for _ in range(N)]

d = {}
for a, b in X:
    if a == b == 0:
        pass
    elif a == 0:
        if b > 0:
            b = 1
        else:
            b = -1
    elif b == 0:
        if a > 0:
            a = 1
        else:
            a = -1
    else:
        v = gcd(a, b)
        a //= v
        b //= v

    if a * b >= 0:
        pair = (abs(a), abs(b))
        if pair not in d:
            d[pair] = [0, 0]
        d[pair][0] += 1
    else:
        pair = (abs(b), abs(a))
        if pair not in d:
            d[pair] = [0, 0]
        d[pair][1] += 1

mod = 10 ** 9 + 7
zero = 0
ans = 1
for p in d:
    if p == (0, 0):
        zero = d[p]
    else:
        a, b = d[p]
        ans *= pow(2, a, mod) + pow(2, b, mod) - 1
        
print(ans + zero - 1)


### FIXED CODE ###

from collections import defaultdict
from math import gcd

N = int(input())
X = [list(map(int, input().split())) for _ in range(N)]

d = {}
for a, b in X:
    if a == b == 0:
        pass
    elif a == 0:
        if b > 0:
            b = 1
        else:
            b = -1
    elif b == 0:
        if a > 0:
            a = 1
        else:
            a = -1
    else:
        v = gcd(a, b)
        a //= v
        b //= v

    if (a > 0 and b >= 0) or (a < 0 and b <= 0):
        pair = (abs(a), abs(b))
        if pair not in d:
            d[pair] = [0, 0]
        d[pair][0] += 1
    else:
        pair = (abs(b), abs(a))
        if pair not in d:
            d[pair] = [0, 0]
        d[pair][1] += 1

mod = 10 ** 9 + 7
zero = 0
ans = 1
for p in d:
    if p == (0, 0):
        zero = d[p][1]
    else:
        a, b = d[p]
        ans *= pow(2, a, mod) + pow(2, b, mod) - 1
        ans %= mod
        
print((ans + zero - 1) % mod)
def o(a,b):
  if a>2*b:
    return a-2*b
  return 0
 
a=imput()
b=imput()
print(o(a,b))

### FIXED CODE ###

a,b=map(int, input().split())
if a>2*b:
  print(a-2*b)
else:
  print(0)
def main():
    N = int(sys.stdin.readline())
    p = list(map(int, input().split()))
    count = 0
    for i, n in enumerate(p, 1):
        if i == n:
            p[i - 1], p[i] = p[i], p[i - 1]
            count += 1
    print(count)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

def main():
    N = int(sys.stdin.readline())
    p = list(map(int, input().split()))
    count = 0
    for i, n in enumerate(p, 1):
        if i == n:
            count += 1
            if len(p) != i:
                p[i - 1], p[i] = p[i], p[i - 1]
    print(count)

if __name__ == '__main__':
    main()
n = int(input())
x=[]
y=[]
h=[]
for i in range(0,n):
    a,b,c = map(int,input().split())
    x.append(a)
    y.append(b)
    h.append(c)
 
 
 
for i in range(0,101):
    for j in range(0,101):
        tmph=0
        flag = True
        for k in range(0,n):
            if tmph == 0 and h[k] != 0:
                tmph=abs(x[k]-i)+abs(y[k]-j)+h[k]
                break
            for k in range(0,n):
            calch = tmph - abs(x[k]-i)-abs(y[k]-j)
            if h[k] != max(calch,0):
                flag = False
                break
        if flag == False:
            continue
        elif tmph == 0:
            flag2 = True
            for c in range(0,101):
                if i == x[c] and j == y[c]:
                    flag2 = False
                    break
            if flag2:
                ansx = i
                ansy = j
                ansh = 1
        else:
            ansx=i
            ansy=j
            ansh=tmph
 
print(ansx,ansy,ansh)

### FIXED CODE ###

n = int(input())
x=[]
y=[]
h=[]
for i in range(0,n):
    a,b,c = map(int,input().split())
    x.append(a)
    y.append(b)
    h.append(c)
 
 
 
for i in range(0,101):
    for j in range(0,101):
        tmph=0
        flag = True
        for k in range(0,n):
            if tmph == 0 and h[k] != 0:
                tmph=abs(x[k]-i)+abs(y[k]-j)+h[k]
                break
        for k in range(0,n):
            calch = tmph - abs(x[k]-i)-abs(y[k]-j)
            if h[k] != max(calch,0):
                flag = False
                break
        if flag == False:
            continue
        elif tmph == 0:
            flag2 = True
            for c in range(0,101):
                if i == x[c] and j == y[c]:
                    flag2 = False
                    break
            if flag2:
                ansx = i
                ansy = j
                ansh = 1
        else:
            ansx=i
            ansy=j
            ansh=tmph
 
print(ansx,ansy,ansh)
while 1:
H , W = map(int, raw_input().split())

if H == W == 0:
  break

for i in range(W):
  width += "#"
for j in range(H):
  print width
    
    

### FIXED CODE ###

while 1:
  h, w = map(int, raw_input().split())
  if h == 0 and w == 0:
    break
  for i in range(h):
    print "#" * w
  print""
import sys
import numpy as np

n = int(sys.stdin.readline().rstrip())
xy = [[] for _ in range(n)]
for i in range(n):
    a = int(sys.stdin.readline().rstrip())
    for _ in range(a):
        x, y = map(int, sys.stdin.readline().split())
        xy[i].append((x - 1, y))

def main():

    res = np.full(2 ** n, 1, np.int64).reshape(-1, 1)
    comb = np.arange(2 ** n).reshape(-1, 1)
    for i in range(n):
        for x, y in xy[i]:
            bl = (comb >> i & 1) ^ (comb >> x & 1 ^ y)
            res &= bl
    
    cand = np.where(res == 1)[0]
    if not cand:
        return 0

    ans = np.amax(np.sum(cand.reshape(-1, 1) >> np.arange(n) & 1, axis=1))
    return ans    
                
if __name__ == '__main__':
    ans = main()
    print(ans)

### FIXED CODE ###

import sys
# import numpy as np

n = int(sys.stdin.readline().rstrip())
xy = [[] for _ in range(n)]

for i in range(n):
    a = int(sys.stdin.readline().rstrip())
    for j in range(a):
        x, y = map(int, sys.stdin.readline().split())
        xy[i].append((x-1, y))

# xy = np.array(xy)
# x, y = xy[:, :].T
# x = x.T 
# y = y.T

def main():
    ans = 0
    for comb in range(2 ** n):
        cnt = 0
        ok = True
        for i in range(n):
            if not comb >> i & 1:
                continue
            for x, y in xy[i]:
                if comb >> x & 1 ^ y:
                    ok = False
                    break
            if ok:
                cnt += 1
            else:
                break
        else:
            ans = max(ans, cnt)
    return ans
                
if __name__ == '__main__':
    ans = main()
    print(ans)
N, M = map(int, input().split())
vote = list(map(int, input().split()))
sum = sum(vote)
cnt = 0


for i in range(0,len(vote)):
    if sum / 4 / M <= vote[i]:
        cnt++


if cnt >= M:
    print("Yes")
else: print("No")


### FIXED CODE ###

N, M = map(int, input().split())
vote = list(map(int, input().split()))
sum = sum(vote)
allowedList = []


for i in range(0,len(vote)):
    if sum / 4 / M <= vote[i]:
        allowedList.append(vote[i])


if len(allowedList) >= M:
    print("Yes")
else: print("No")
n,m = map(int, input().split())
p = [0] * m
s = [0] * m
for i in range(m):
    p[i], s[i] = map(int, input().split())
AC=[]
AC1=[]
WA=0
for i in range(m):
    if s[i]=="AC" and p[i] not in AC:
        AC.append(p[i])
        AC1.append(i)
for i in range(m):
    if s[i]=="WA" and p[i] in AC:
        if AC1[AC.index(p[i])]>i:
            WA=WA+1
print(len(AC),WA)

### FIXED CODE ###

n,m = map(int, input().split())
p = [0]*m 

for i in range(m):
    p[i] = input().split()
AC=[[0,-1] for j in range(n)]
k=0
WA=0
for i in range(m):
    if p[i][1]=="AC" and AC[int(p[i][0])-1][0]==0 :
        AC[int(p[i][0])-1][0]=1
        AC[int(p[i][0])-1][1]=i
        k=k+1
for i in range(m):
    if p[i][1]=="WA" and AC[int(p[i][0])-1][0]==1 and AC[int(p[i][0])-1][1]>i:
        WA=WA+1

print(k,WA)
K = int(input())
N = int(input())
A = {}
for i in range(N):
    A[i] = int(input())
max = 0
for i in range(N):
    len = 0
    if i == 0:
        len = int(A[i] + (K - A[N - 1]))
    else:
        len = int(A[i] - A[i - 1])

    if len > max:
        max = len

print(K - max)

### FIXED CODE ###

K, N = map(int, input().split())
A = list(map(int, input().split()))
max = 0
for i in range(N):
    len = 0
    if i == 0:
        len = int(A[i] + (K - A[N - 1]))
    else:
        len = int(A[i] - A[i - 1])

    if len > max:
        max = len

print(K - max)