Harryxun/stf_run huggingface dataset:
if sys.argv[-1] == 'ONLINE_JUDGE':
    assert False
    exit()

print('RE or WA')

### FIXED CODE ###

import os
import sys

import numpy as np
from heapq import heappop, heappush, heapify


def solve(inp):
    def fenwick_add(arr, n, i, x):
        while i <= n:
            arr[i] += x
            i += i & -i

    def fenwick_sum(arr, i):
        result = 0
        while i > 0:
            result += arr[i]
            i ^= i & -i
        return result

    def fenwick_lower_bound(arr, n, log_n, x):
        sum_ = 0
        pos = 0
        for i in range(log_n, -1, -1):
            k = pos + (1 << i)
            if k < n and sum_ + arr[k] < x:
                sum_ += arr[k]
                pos += 1 << i
        return pos + 1

    def bit_length(x):
        res = 0
        while x:
            res += 1
            x >>= 1
        return res

    h = inp[0]
    w = inp[1]
    aaa = inp[2::2]
    bbb = inp[3::2]

    w1 = w + 1
    log_w = bit_length(w1)
    arr = np.zeros(w1 + 1, dtype=np.int64)
    for j in range(1, w1):
        arr[j] = j & -j
    fenwick_add(arr, w1, w1, 10 ** 18)
    horizontal = np.zeros(w + 1, dtype=np.int64)
    horizontal_rev = np.arange(w + 1, dtype=np.int64)
    q = [(0, j) for j in range(1, w + 1)]
    heapify(q)

    ans = np.full(h, -1, dtype=np.int64)

    for row in range(h):
        a = aaa[row]
        b = bbb[row]
        k = 1 if a == 1 else fenwick_sum(arr, a - 1) + 1
        c = fenwick_lower_bound(arr, w1, log_w, k)
        stack = []
        while c <= b + 1:
            stack.append(c)
            if c == w1:
                break
            k += 1
            c = fenwick_lower_bound(arr, w1, log_w, k)
        # print(a, b, k, c, horizontal, stack)

        if len(stack) == 0:
            ans[row] = row + q[0][0] + 1
            continue

        if stack[-1] == w1:
            found_nearest = True
            stack.pop()
        else:
            found_nearest = False
        stack.reverse()

        for c in stack:
            if found_nearest:
                fenwick_add(arr, w1, c, -1)
                horizontal[horizontal_rev[c]] = -1
            elif c == b + 1:
                found_nearest = True
            else:
                orig = horizontal_rev[c]
                horizontal[orig] = b + 1 - orig
                horizontal_rev[b + 1] = orig
                fenwick_add(arr, w1, c, -1)
                fenwick_add(arr, w1, b + 1, 1)
                heappush(q, (horizontal[orig], orig))
                found_nearest = True

        while q and q[0][0] != horizontal[q[0][1]]:
            heappop(q)

        if len(q) == 0:
            break

        ans[row] = row + q[0][0] + 1

    return ans


if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC

    cc = CC('my_module')
    cc.export('solve', '(i8[:],)')(solve)
    cc.compile()
    exit()

if os.name == 'posix':
    # noinspection PyUnresolvedReferences
    from my_module import solve
else:
    from numba import njit

    solve = njit('(i8[:],)', cache=True)(solve)
    print('compiled', file=sys.stderr)

inp = np.fromstring(sys.stdin.read(), dtype=np.int64, sep=' ')
ans = solve(inp)
print('\n'.join(map(str, ans)))
#実験をしっかりとしよう
X,Y,Z,K = (int(_) for _ in input().split())
A = (int(_) for _ in input().split())
B = (int(_) for _ in input().split())
C = (int(_) for _ in input().split())
#この手の問題はまずsortする(今回は大きい順の方がすっきり)
A = sorted(A)
B = sorted(B)
C = sorted(C)
#Aのa位とb位とc位ならその上にはa*b*c-1(自分以外)が上にいる。
A.reverse()
B.reverse()
C.reverse()

ABC = []
for i in range(len(A)):
    for j in range(len(B)):
        if (i+1)*(j+1) > K:
            break
        for k in range(len(C)):
            if (i+1)*(j+1)*(k+1) > K:
                break
            ABC.append(A[i]+B[j]+C[k])
ABC.sort().reverse()

for i in range(K):
    print(ABC[i])
#pythonだとTLEになる?


### FIXED CODE ###

#実験をしっかりとしよう
X,Y,Z,K = (int(_) for _ in input().split())
A = (int(_) for _ in input().split())
B = (int(_) for _ in input().split())
C = (int(_) for _ in input().split())
#この手の問題はまずsortする(今回は大きい順の方がすっきり)
A = sorted(A)
B = sorted(B)
C = sorted(C)
#Aのa位とb位とc位ならその上にはa*b*c-1(自分以外)が上にいる。
A.reverse()
B.reverse()
C.reverse()

ABC = []
for i in range(len(A)):
    for j in range(len(B)):
        if (i+1)*(j+1) > K:
            break
        for k in range(len(C)):
            if (i+1)*(j+1)*(k+1) > K:
                break
            ABC.append(A[i]+B[j]+C[k])
ABC.sort()
ABC.reverse()

for i in range(K):
    print(ABC[i])
#pythonだとTLEになる?
M=998244353
n,m,k=map(int,input().split())
p,c=[m]*n,[1]*n
for i in range(1,n):
  p[i]=p[i-1]*(m-1)%M
  c[i]=c[i-1]*(n-i)*pow(i,M-2,M)%M
print(sum(p[n-i-1]*c[i]%M for i in range(k+1))%M)

### FIXED CODE ###

import sys
#import cython

def main():
    read = lambda: sys.stdin.readline().rstrip()
    
    #N: cython.longlong = 0
    s = read()
    t = read()
    print("Yes" if t[:-1] == s else "No")
    #a, b, c = map(int,read().split())
    #l = [int(read()) for _ in range(5)]
    

 
if __name__ == "__main__":
    main()
A,B=map(int,input().split())
S=input()
if (S[0:A].isdecimal()==True) and (S[A+1:-1].isdecimal()==True) and (S[A]=='-') and len(S)==x+y+1:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

A,B=map(int,input().split())
S=input()
if S[:A].isdecimal() and S[A+1:].isdecimal() and S.count('-')==1 and len(S)==(A+B+1):
    print('Yes')
else:
    print('No')
# -*- coding: utf-8 -*-
# モジュールのインポート
import sympy as sp

# 標準入力を取得
N = int(input())

# 求解処理
ans = 0
for n in range(1, N + 1, 2):
    if sp.divisor_count(n) == 8:
        ans += 1

# 結果出力
print(ans)


### FIXED CODE ###

# -*- coding: utf-8 -*-
# 標準入力を取得
N = int(input())

# 求解処理
ans = 0
for n in range(1, N + 1, 2):
    divisors_count = 0
    for i in range(1, n + 1):
        if n % i == 0:
            divisors_count += 1
    if divisors_count == 8:
        ans += 1

# 結果出力
print(ans)
N = int(input())
inputs = [list(map(int, input().split())) for _ in range(N)]

dicts = {}
for i in range(N):
    dicts[i] = sum(inputs[i])

ans = ~
count = 0
for key, value in sorted(dicts.items(), key=lambda x: -x[1]):
    if count % 2 == 0:
        ans += inputs[key][0]
    else:
        ans -= inputs[key][1]
    count += 1

print(ans)


### FIXED CODE ###

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

dicts = {}
for i in range(N):
    dicts[i] = sum(inputs[i])

t = 0
a = 0
count = 0
for key, value in sorted(dicts.items(), key=lambda x: -x[1]):
    if count % 2 == 0:
        t += inputs[key][0]
    else:
        a += inputs[key][1]
    count += 1

print(t - a)
A, B, C, D = map(int, input().split())

flg = true
t = false
while(flg):
  t = true
  D -= B
  if (D <= 0):
    break
  t = false
  A -= C
  if (A <= 0) :
    break

if (t):
  print("Yes")
else:
  print("No")
  

### FIXED CODE ###

A, B, C, D = map(int, input().split())
 
flg = True
t = False
while(flg):
  C -= B
  if (C <= 0):
    t = True
    break
  A -= D
  if (A <= 0) :
    t = False
    break

if (t):
  print("Yes")
else:
  print("No")
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    # 最短経路問題で使われるアルゴリズムの１つ。
    # グラフ上の全ての頂点間の最短経路を探す
    # 負の閉路（辺の重みの和が負になるような閉路）がない限り、負の辺があっても使える。

    # 負の閉路を持つ場合は'NEGATIVE CYCLE'を、そうでない場合には(i,j)成分に
    # 頂点iから頂点jへの最短経路の距離を格納するdist_listをprintする関数
    def warshall_floyd(v_num, dist_lst):
        for k in range(v_num):
            for i in range(v_num):
                for j in range(v_num):
                    # i→k→jがつながっててしかもi→jルートよりもイケてるなら更新
                    if dist_lst[i][k] != INF and dist_lst[k][j] != INF:
                        if dist_lst[i][j] > dist_lst[i][k] + dist_lst[k][j]:
                            dist_lst[i][j] = dist_lst[i][k] + dist_lst[k][j]

        return dist_lst

    H, W = map(int, input().split())
    # 頂点の数と辺の数
    v_num, e_num = 10, 100

    # 配列dist_lst[a][b]には頂点a,b間の辺のコストを入れておき、
    # a=bの時は0を、a,b間の辺が存在しないときはINFを入れておく。
    INF = 10 ** 20
    dist_lst = [[INF] * v_num for _ in range(v_num)]

    costs = [[i for i in list(map(int, input().split()))] for _ in range(10)]
    for s in range(10):
        for t in range(10):
            dist_lst[s][t] = costs[s][t]

    dist_lst = warshall_floyd(v_num, dist_lst)
    wall = [[i for i in list(map(int, input().split()))] for _ in range(10)]
    cnt = 0
    for h in range(H):
        for w in range(W):
            val = wall[h][w]
            if val == -1 or val == 1:
                continue
            else:
                cnt += dist_lst[val][1]
    print(cnt)


resolve()

### FIXED CODE ###

from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall

import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    H, W = map(int, input().split())

    graph = [[i for i in list(map(int, input().split()))] for _ in range(10)]
    graph = csr_matrix(graph)

    dist_matrix = floyd_warshall(csgraph=graph, directed=True, return_predecessors=False)
    dist_matrix = list(dist_matrix)

    wall = [[i for i in list(map(int, input().split()))] for _ in range(H)]

    cnt = 0
    for h in range(H):
        for w in range(W):
            val = wall[h][w]
            if val != -1 and val != 1:
                cnt += dist_matrix[val][1]
    print(int(cnt))


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

flag = 1
for i in range(len(h)-1):
    for j in range(i+1,len(h)):
        if(h[i]-h[j]>=2):
            print("No")
            flag=0
            break
    if(flag==0):
        break
            
if(flag==1):
    print("Yes")

### FIXED CODE ###

a,b,c = (int(i) for i in input().split())

if(b+c-a>=0):
  print(b+c-a)
else:
  print(0)
import math
N = int(input())
print(math.floor(1 / 2 * N * (N - 1)))


### FIXED CODE ###

S = input()
T = input()
count = 0
for (s, t) in zip(S, T):
    if s == t:
        count += 1
print(count)
L, R = map(int, input().split())

LARGE = 10 ** 9 + 7


def get_l(vl, le_r):
    # vl <= L <= R <= 2 ** le_r - 1
    res_ = 0

    if vl == 0:
        res_ += pow(2, le_r, LARGE)
        vl = 1
    for l_ in range(le_r):
        if vl % (2 ** (l_ + 1)) != 0:
            le_total = le_r - bin(vl).count("1")
            res_ += pow(3, l_, LARGE) * pow(2, le_total - l_, LARGE)
            res_ %= LARGE
            vl += 2 ** l_
    return res_


def get_r(vr):
    # 0 <= L <= R <= vr
    if vr == 0:
        return 1
    elif vr == 1:
        return 2
    l_ = 0
    while True:
        if 2 ** (l_ + 1) - 1 > vr:
            break
        l_ += 1

    return (pow(3, l_, LARGE) + 2 * get_r(vr - 2 ** l_)) % LARGE


res = 0
le = 0
left = 2 ** le
right = 2 ** (le + 1) - 1


while True:
    if right < L:
        pass
    elif L < left < right < R:
        res += pow(3, le, LARGE)
    elif R < left:
        break
    elif left <= L <= right < R:
        res += get_l(L, le + 1)
    elif L < left <= R <= right:
        res += get_r(R - left)
    elif L < R:
        # left <= L <= R <= right:
        # find mid
        mid = left
        for le2 in range(le - 1, -1, -1):
            if L < mid + 2 ** le2 <= R:
                res += get_l(L - mid, le2)
                res += get_r(R - mid)
            elif mid + 2 ** le2 <= L:
                mid += 2 ** le2
            else:
                pass
    else:
        res = 1

    res %= LARGE
    le += 1
    left *= 2
    right *= 2
    right += 1

print(res)


### FIXED CODE ###


LARGE = 10 ** 9 + 7

# flag_x : left < x
# flag_y : y < right
# flag_z : msb


def f(pos, flag_x, flag_y, flag_z, memo, left, right):
    if pos == -1:
        return 1
    if memo[pos][flag_x][flag_y][flag_z] != -1:
        return memo[pos][flag_x][flag_y][flag_z]
    ret = 0
    # x 0, y 0
    if flag_x or left[pos] == '0':
        ret += f(pos - 1, flag_x, 1 if right[pos] == '1' else flag_y, flag_z, memo, left, right)
    # x 0, y 1
    if (flag_x or left[pos] == '0') and (flag_y or right[pos] == '1') and flag_z:
        ret += f(pos - 1, flag_x, flag_y, flag_z, memo, left, right)
    # x 1, y 1
    if flag_y or right[pos] == '1':
        ret += f(pos - 1, 1 if left[pos] == '0' else flag_x, flag_y, 1, memo, left, right)
    ret %= LARGE
    memo[pos][flag_x][flag_y][flag_z] = ret
    return ret


def solve_greed_f(L, R):

    res_g = 0

    for i in range(L, R + 1):
        for j in range(i, R + 1):
            if j % i == j ^ i:
                res_g += 1

    return res_g


def main():

    ll, rr = map(int, input().split())

    left = '{:060b}'.format(ll)[::-1]
    right = '{:060b}'.format(rr)[::-1]

    memo = [[[[-1 for m in range(2)] for k in range(2)] for j in range(2)] for i in range(60)]

    res = f(59, 0, 0, 0, memo, left, right)

    print(res)


if __name__ == "__main__":
    main()
S =int(input())
W =int(input())

if (S <= W) and 0 <= S,W <= 100: 
    print('unsafe')
else:
    print('safe')

### FIXED CODE ###

S,W=(int(x) for x in input().split())

if S <= W:
  print('unsafe')
else:
  print('safe')
from fractions import Fraction as fa

n = int(input())
arr= [int(x) for x in input().split()]
ans = 0
for i in arr:
  ans += fa(1,i)
  
ans = str(ans).split('/')

print(ans[1]/ans[0])

### FIXED CODE ###

n = int(input())
arr= [1/int(x) for x in input().split()]
print(1/sum(arr))
N=list(input())

n=reversed(N)

if n[0]=="2" or n[0]=="4" or n[0]=="5" or n[0]=="7" or n[0]=="9":
    print(pon)

### FIXED CODE ###

n=list(input())

n==n.reverse()

if (n[0]=="2" or n[0]=="4" or n[0]=="5" or n[0]=="7" or n[0]=="9"):
    print("hon")
elif (n[0]=="0" or n[0]=="1" or n[0]=="6" or n[0]=="8"):
    print("pon")
elif (n[0]=="3"):
    print("bon")
def func(arr):
    crr=[0 for i in range(len(arr))]
    crr[0]=arr[0]
    crr[1]=arr[1]-arr[0]
    for i in range(2,len(arr)):
        crr[i]=min(abs((arr[i]-arr[i-1]))+crr[i-1],abs((arr[i]-arr[i-2]))+crr[i-2])
    print(crr)
    
b=input()
ar=list(map(int,input().split())
func(ar)

### FIXED CODE ###

def func(arr):
    crr=[0 for i in range(len(arr))]
    crr[0]=0
    crr[1]=abs(arr[1]-arr[0])
    for i in range(2,len(arr)):
        crr[i]=min(abs((arr[i]-arr[i-1]))+crr[i-1],abs((arr[i]-arr[i-2]))+crr[i-2])
    print(crr[-1])

b=input()
cr=list(map(int,input().split()))
func(cr)
def datasets():
    while True:
        h, w = [int(nv) for nv in raw_input().split()]
        if h == w == 0:
            return
        yield h, w

for h, w in datasets():
    print '#'*w
    for i in range(h-2)
        print '#' + ' '*(w-2) + '#'
    print '#'*w

### FIXED CODE ###

from __future__ import print_function

FC = '#'
PC = '.'

def bothends(f):
    def _func(self):
        print(FC, end='')
        f(self)
        print(FC)
    return _func

class Frame:
    c = FC
    s = PC
    def __init__(self, w, h):
        self.w = w
        self.h = h
        
    @bothends
    def _draw(self):
        print(self.s * (self.w - 2), end='')

    def draw(self):
        for i in range(self.h - 2):
            self._draw()

    def __enter__(self):
        print(self.c * self.w)
        return self

    def __exit__(self, exc_type, exc_value, traceback):
        print(self.c * self.w)
        return True

while True:
    w, h = [ int(s) for s in raw_input().split() ]
    if w == h == 0:
        break
    with Frame(h, w) as fr:
        fr.draw()
    print()
import numpy as np
n = int(input())
a_lst = list(map(int,input().split()))

ans = np.prod(a_lst)
if ans > 10**18:
    print("-1")
else:
    print(ans)

### FIXED CODE ###

n = int(input())
a_lst = list(map(int,input().split()))

ans = 1
if 0 in a_lst:
    print(0)
else:
    for a in a_lst:
        ans *= a
        if ans > 10**18:
            ans = -1
            break
    print(ans)
s=str(input())
t=str(input())
ans=0
f=[]
g=len(s)
h=len(t)
for i in range(g-h):
    for j in range(h):
        if s[i+j]!=t[j]:
            ans+=1
    f.append(ans)
    ans=0
    f.sort()
print(f[0])



### FIXED CODE ###

S = input()
T = input()
n = len(S)
m = len(T)
x = int(1e9)
for i in range(n-m+1):
  cnt = 0
  for j in range(m):
    cnt += (S[i+j] != T[j])
  x = min(x, cnt)
print(x)
import itertools
min_price = 10**9
for k in range(n):
    for comb in itertools.combinations(range(m), k+1):
        sums = [0] * m
        price = 0
        for c in comb:
            price += C[c]
            for i in range(m):
                sums[i] += A[c][i]

#         print(comb)
#         print(sums)
        if sum([y >= x for y in sums]) == len(A):
            min_price = min(min_price, price)

if min_price == 10**9:
    print('-1')
else:
    print(min_price)

### FIXED CODE ###

import itertools

n,m,x = map(int,input().split())
C, A = [], []
for i in range(n):
    ca = list(map(int, input().split()))
    C.append(ca[0])
    A.append(ca[1:])

min_price = 10**9
for k in range(n):
    for comb in itertools.combinations(range(n), k+1):
        sums = [0] * m
        price = 0
        for c in comb:
            price += C[c]
            for i in range(m):
                sums[i] += A[c][i]

#         print(comb)
#         print(sums)
#         print(min_price)
        if sum([y >= x for y in sums]) == m:
            min_price = min(min_price, price)

if min_price == 10**9:
    print('-1')
else:
    print(min_price)
#!/usr/bin/env python3
#abc126 e

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

G = [[] for _ in range(N)]

for i in XYZ:
    G[i[0]-1].append(i[1])
    G[i[1]-1].append(i[0])

check = [False for _ in range(N+1)]#各頂点を訪問したかどうか
def DFS(G,s):
    check[s-1] = True
    for i in G[s-1]:
        if not check[i-1]:
            DFS(G,i)
    return
ans = 0
for i in range(N):
    if not check[i]:
        DFS(G,i+1)
        ans += 1
print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
#abc126 e

import sys
sys.setrecursionlimit(1000000)
N,M = list(map(int,input().split()))
XYZ = [list(map(int,input().split())) for _ in range(M)]

G = [[] for _ in range(N)]

for i in XYZ:
    G[i[0]-1].append(i[1])
    G[i[1]-1].append(i[0])

check = [False for _ in range(N)]#各頂点を訪問したかどうか

def DFS(G,s):
    check[s-1] = True
    for i in G[s-1]:
        if not check[i-1]:
            DFS(G,i)
ans = 0
for i in range(N):
    if not check[i]:
        DFS(G,i+1)
        ans += 1
print(ans)
n=int(input()) 
alist=list(map(int,input().split()))
a=1
if 0 in alist:
    print("0")
else:
    for i in alist:
        if a<=10**18:
            a=a*i
        else:
            break
    if a>10**18:
        print('-1')
    else:
        print(a)

### FIXED CODE ###

a,b=map(int,input().split())
print(a*b)
n,k = map(int,input().split())
s = set()
for i in range(k):
    d = int(input())
    l = list(map(int,input().split()))
    for i in l:
        s.add(i)
print(n-len(s))

### FIXED CODE ###

s = input()
print("ARC" if s == "ABC" else "ABC")
import copy

n,k,c = map(int, input().split())
s = input()
S = []
lst = [[] for i in range(n)]
# print(lst)
for i in range(len(s)):
    if s[i]=="o":
        S.append(i)
# print("S:",S)
for i in range(len(S)-1):
    koho = S[i+1:]
    for j in koho:
        if j>S[i]+c:
            lst[S[i]].append(j)
    # lst[S[i]].append(S[i+1:])
# print("lst:",lst)



ans = []
for i in S:
    testlst = copy.deepcopy(lst)
    testlst[i] = []
    for j in range(n):
        if testlst[j]!=[]:
            if  testlst[j][0]==i:
                testlst[j].remove(i)
    # print("i,testlst:",i,testlst)

    count = 1
    if i==S[0]:
        num = S[1]
    else:
        num = S[0]
    while testlst[num]!=[]:
        num = testlst[num][0]
        count += 1
    if count < k:
        ans.append(i+1)

for i in ans:
    print(i)


### FIXED CODE ###

n,k,c = map(int, input().split())
s = input()

asc = []
des = []

count = 0
while count<n:
    if s[count]=="o":
        asc.append(count)
        count += c+1
    else:
        count += 1
asc = asc[0:k]

count = n-1
while count>=0:
    if s[count]=="o":
        des.append(count)
        count -= c+1
    else:
        count -= 1
des = des[0:k]
des.reverse()

# print(asc)
# print(des)

for i in range(len(asc)):
    if asc[i]==des[i]:
        print(asc[i]+1)
a,b,k = map(int,input().split())

x =list(range(a,b+1))
ans =[]

if  len(x) >=i:
  print("\n".join(map(str,x)))
  exit()

else:
  for i in range(k):
    if len(x) > i:
      if not(x[i] in ans):
        ans.append(x[i])
      if not(x[-(1+i)] in ans):
        ans.append(x[-(1+i)])
  
  ans.sort()

s = "\n".join(map(str,ans))
print(s)



### FIXED CODE ###

A,B,K = map(int,input().split())
            
ans=[]
            
for i in range(K):
  if A+i <=B:
    ans.append(A+i)
  if B-i >= A:
    ans.append(B-i)
            
            
ans = sorted(list(set(ans)))
print(*ans,sep="\n")
abc = list(map(int, input()))

print("Yes" if sorted(abc) == [5, 5, 7] else "No")

### FIXED CODE ###

abc = list(map(int, input().split(" ")))

print("YES" if sorted(abc) == [5, 5, 7] else "NO")
N = int(input())

ans = -1
for i in range(N)
	if round(i*1.08) == N:
    	ans = i
      
if ans == -1:
  print(':(')
  
else:
  print(ans)

### FIXED CODE ###

import math

N = int(input())
ans = -1
for i in range(N+1):
	if math.floor(i*1.08) == N:
		ans = i
if ans == -1:
	print(':(')
else:
	print(ans)
N,M = map(int, input().split())

P = [list(map(int,input().split())) for i in range(M)]
s=[]
c=[]

for i in range(M):
    s.append(P[i][0])
    c.append(P[i][1])
A=[-1]*N

k=0
for i in range (M):
    if (A[s[i]-1]==-1) or (A[s[i]-1]==c[i]):
        A[s[i]-1]=c[i]
    else:
        k=1
        print(-1)
aa=0
if A[0]==0 and N>1:
    k=1
    print(-1)
if M==0:
    k=1
    print(pow(10,(N-1)))
if k==0:
    for i in range (M):
        if A[i]==-1:
            A[i] = 0
            if A[0]==0:
                A[0]=1

        aa+=A[i]*pow(10,(M-i-1))

    print(aa)


### FIXED CODE ###

N,M = map(int, input().split())

P = [list(map(int,input().split())) for i in range(M)]
s=[]
c=[]

for i in range(M):
    s.append(P[i][0])
    c.append(P[i][1])
A=[-1]*N

k=0
for i in range (M):
    if (A[s[i]-1]==-1) or (A[s[i]-1]==c[i]):
        A[s[i]-1]=c[i]
    else:
        k=1
        print(-1)
aa=0
if A[0]==0 and N>1:
    k=1
    print(-1)
if M==0:
    k=1
    if N==1:
        print(0)
    else:
        print(pow(10,(N-1)))

if k==0:
    for i in range (N):
        if A[i]==-1:
            A[i] = 0
            if A[0]==0:
                A[0]=1

        aa+=A[i]*pow(10,(N-i-1))

    print(aa)
data = [
    [[0 for r in range(10)]for f in range(3)] for b in range(4)
]

# ??\??????????????????????????§????????????????????????????????????


for b in enumerate(data):
    for f in b:
        for r in f:
            print(' {0}'.format(r), end='')

        print()

    if bi < 3:
    ??????print('#'* 20)

### FIXED CODE ###

data = [
    [[0 for r in range(10)] for f in range(3)] for b in range(4)
]
 
count =int(input())
for c in range(count):
    b, f, r, v = [int(i) for i in input().split()]
    data[b-1][f-1][r-1] += v
 
for bi, b in enumerate(data):
    for f in b:
        for r in f:
            print(' {0}'.format(r), end='')
 
        print()
    if bi < 3:
        print('#' * 20)
n=int(input())
X=[]
Y=[]
A=[0]*n
for i in range(n):
  A[i]=int(input())
  a=A[i]
  x=[]
  y=[]
  for j in range(a):
    x,y=[int(s) for s in input().split()]
  X.append(x)
  Y.append(y)
  
c=0
for i in range(n):
  l=[1]*n
  for j in range(i,n-i):
    if l[j]==0:continue
    for k in range(A[j]):
      b=2
      b=X[k][j]
      #l[b] *= Y[j][k]

if c < l.count(1):
  c=l.count(1) 
  
        
  
print(c)  
   

### FIXED CODE ###

n=int(input())
X=[]
Y=[]
A=[0]*n
for i in range(n):
  A[i]=int(input())
  a=A[i]
  x=[0]*a
  y=[0]*a
  for j in range(a):
    x[j],y[j]=[int(s) for s in input().split()]
  X.append(x)
  Y.append(y)
  
s=0
for i in range(2**n):
  c=0
  d=0
  B=[0]*n
  for j in range(n):
    if((i >> j) & 1):
      c=c+1
      B[j]=1
  for k in range(n):
    if B[k]==1:
      for j in range(A[k]):
        if Y[k][j]!=B[X[k][j]-1]:
          d=-1
          break
    if d<0:
      break
  if s<c and d==0:
    s=c
      
      
print(s)