Harryxun/stf_run huggingface dataset:
n,k = map(int, input().split())
A = []
d = []
for i in range(k):
    d[i] = int(input())
    A[i] = list(map(int, input().split()))

for j in range(k):
    for k in range(d[j]):
        a = set(A[j][k])

print(n-len(a))

### FIXED CODE ###

n,k = map(int, input().split())
d = []
A= []
c = []
 
for i in range(k):
    d.append(int(input()))
    A.append(list(map(int, input().split())))
 
for j in range(k):
    for m in range(d[j]):
        c.append(A[j][m])
 
print(n-len(set(c)))
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

"""
dp
time / books_no?
10 0 0
20 0 0
30 0 0
40 0 0
50 0 0
60 1 0
70 1 0
80 0 1




"""



N, M, K = LI()
A = LI()
B = LI()

a = [0 for i in range(2 * 10 ** 5)]
b = [0 for i in range(2 * 10 ** 5)]
a_sum = [0 for i in range(2 * 10**5)]
b_sum = [0 for i in range(2 * 10 ** 5)]

time = 0
sum_a = 0
for i in range(N):
    time += A[i]
    if time > 2 * 10 ** 5:
        break
    a[time] += 1

time = 0
for j in range(M):
    time += B[j]
    if time > 2 * 10 ** 5:
        break
    b[time] += 1

s_a = 0
s_b = 0
for time in range(2*10 **5):
    s_a += a[time]
    a_sum[time] = s_a
    s_b += b[time]
    b_sum[time] = s_b

ans = 0
for i in range(K):
    ans = max(ans, a_sum[i] + b_sum[K - i])
print(ans)

### FIXED CODE ###

#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

"""
dp
time / books_no?
10 0 0
20 0 0
30 0 0
40 0 0
50 0 0
60 1 0
70 1 0
80 0 1




"""



N, M, K = LI()
A = LI()
B = LI()

"""
片方に注目して探索すればよい　

単純にfor,forだと計算量がまずいが，前回の値の部分から探索すればいいのでそこまで
計算量は増えない

"""

a = [0]
b = [0]

for i in range(N):
    a.append(a[-1] + A[i])

for i in range(M):
    b.append(b[-1] + B[i])

# print(a)
ans = 0
j = M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)
#https://atcoder.jp/contests/abc104/tasks/abc104_c

d, g = map(int, input().split())

for i in range(d):
  pc.append(list(map(int,input().split())))

ans = float("inf")

#各配点について解くか解かないかを決め、その上で G 点に満たなければ、まだ解いてない配点のうち一番高い配点のものを足りない分解く

for i in range(2**d):
    count = 0 #解く問題数
    sum = 0
    nokori = set(range(1, d + 1)) #点数の列

    for j in range(d):
        if (i>>j)&1:
            sum += pc[j][0] * (j + 1) * 100 + pc[j][1] #(j+1)*100点+bounus
            count += pc[j][0]
            nokori.discard(j + 1) #(j+1)*100点を処理したので削除

    # G 点に満たなければ nokori のうち一番大きいものを解く
    if sum < g:
        use = max(nokori)
        # 解く問題が問題数を超えないように注意
        n = min(pc[use - 1][0], -(-(g - sum) // (use * 100)))
        count += n
        sum += n * use * 100

    if sum >= g:
        #数が小さい方を残す
        ans = min(ans, count)

print(ans)

### FIXED CODE ###

#https://atcoder.jp/contests/abc104/tasks/abc104_c
 
d, g = map(int, input().split())
pc = []
 
for i in range(d):
  pc.append(list(map(int,input().split())))
 
ans = float("inf")
 
#各配点について解くか解かないかを決め、その上で G 点に満たなければ、まだ解いてない配点のうち一番高い配点のものを足りない分解く
 
for i in range(2**d):
    count = 0 #解く問題数
    sum = 0
    nokori = set(range(1, d + 1)) #点数の列
 
    for j in range(d):
        if (i>>j)&1:
            sum += pc[j][0] * (j + 1) * 100 + pc[j][1] #(j+1)*100点+bounus
            count += pc[j][0]
            nokori.discard(j + 1) #(j+1)*100点を処理したので削除
 
    # G 点に満たなければ nokori のうち一番大きいものを解く
    if sum < g:
        use = max(nokori)
        # 解く問題が問題数を超えないように注意
        n = min(pc[use - 1][0], -(-(g - sum) // (use * 100)))
        count += n
        sum += n * use * 100
 
    if sum >= g:
        #数が小さい方を残す
        ans = min(ans, count)
 
print(ans)
X=int(input())
for i in range(2,X):
  if(X%i==0):
    X+=1
    break
  else :
  	print X

### FIXED CODE ###

def isPrime(x):
  if x < 2:
    return False
  for i in range(2,x):
    if x%i == 0:
      return False
  return True

num = int(input())

for i in range(num,100004):
  if isPrime(i):
    print(i)
    break
n,k=map(int,input().split())
l=[0]*n
for i in range(k):
  d=int(input())
  h=[int(input()) for i in range(d)]
  for j in d:
    l[j-1]=1
print(l.count(0))

### FIXED CODE ###

n,k=map(int,input().split())
l=[0]*n
for i in range(k):
  d=int(input())
  h=list(map(int,input().split()))
  for j in h:
    l[j-1]=1
print(l.count(0))
print(input().strip()+('es' if s[-1] == 's' else 's'))


### FIXED CODE ###

s = input()
print(s+('es' if s[-1] == 's' else 's'))
while True:
	ints = raw_input()
	if ints != '':
		x = map(int,ints.split(' '))
		x.sort()
		a = x[1]
		b = x[0]
		while True:
			m=a%b
			if m!=0:
				a=b
				b=m
				continue
			else:
				break
		n = x[1]*x[0]/b
		print b,n
		continue
	else:
		break

### FIXED CODE ###

while True:
	try:
		while True:
			ints = raw_input()
			if ints != '':
				x = map(int,ints.split(' '))
				x.sort()
				a = x[1]
				b = x[0]
				while True:
					m=a%b
					if m!=0:
						a=b
						b=m
						continue
					else:
						break
				n = x[1]*x[0]/b
				print b,n
				continue
			else:
				break
	except: break
s = input()
k = int(input())
st = set()
for i in range(len(s)):
    for j in range(min(k, len(s)-i)):
        st.add(s[i:i+j])
for _ in range(k-1):
    m = min(st)
    st = [x for x in st if x != m]
print(min(st))

### FIXED CODE ###

s = input()
k = int(input())
st = set()
for i in range(len(s)):
    j = 1
    while j <= k and i+j <= len(s):
        st.add(s[i:i+j])
        j += 1
for _ in range(k-1):
    m = min(st)
    st = [x for x in st if x != m]
print(min(st))
# ABC084C - Special Trains
def main():
    N = int(input())
    A = tuple(tuple(map(int, input().split())) for _ in range(N - 1))
    for i in range(n):
        cur = 0
        for c, s, f in A[i:]:
            if cur <= s:
                cur = s + c
            else:
                cur = (cur + f - 1) // f * f + c
        print(cur)


if __name__ == "__main__":
    main()

### FIXED CODE ###

# ABC084C - Special Trains
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    arr = tuple(tuple(map(int, input().split())) for _ in range(n - 1))
    for i in range(n):
        cur = 0
        for c, s, f in arr[i:]:
            if cur <= s:
                cur = s + c
            else:
                cur = (cur + f - 1) // f * f + c
        print(cur)


if __name__ == "__main__":
    main()
aaa = [0,1,1,2,2,2,3,3,3,3,4,4,4,4,4,5,5,5,5,5,5,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7]

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
N = int(input())
l = factorization(N) 

ans = 0

for arr in l:
  if arr[0] != 1:
    a = arr[1]
    b = aaa[a]
    ans += b
  
print(ans)

### FIXED CODE ###


aaa = [0,1,1,2,2,2,3,3,3,3,4,4,4,4,4,5,5,5,5,5,5,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8]

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
N = int(input())
l = factorization(N) 

ans = 0

for arr in l:
  if arr[0] != 1:
    a = arr[1]
    b = aaa[a]
    ans += b
  
print(ans)
import math
for i in range(input()):
    x1,y1,x2,y2,x3,y3=map(float,raw_input().split(" "))
    if y2==y1 or y3==y1:
        if y2==y1:
            a2=-(x3-x1)/(y3-y1)
            b2=((y3+y1)-a2*(x1+x3))/2
            a,b,c,d,e,f,=0,1,(x1+x2)/2,-a2,1,b2
        else:
            a1=-(x2-x1)/(y2-y1)
            b1=((y2+y1)-a2*(x1+x2))/2
            a,b,c,d,e,f,=-a1,1,b1,0,1,(x1+x3)/2
    else:
        a1=-(x2-x1)/(y2-y1)
        a2=-(x3-x1)/(y3-y1)
        b1=((y2+y1)-a1*(x1+x2))/2
        b2=((y3+y1)-a2*(x1+x3))/2
        a,b,c,d,e,f,=-a1,1,b1,-a2,1,b2
    py=(a*f-c*d)/(a*e-b*d)
    px=(c*e-f*b)/(a*e-b*d)
    r=math.sqrt((px-x1)**2 + (py-y1)**2)
    print "{0:.3f} {1:.3f} {2:.3f}".format(px,py,r)

### FIXED CODE ###

import math
for i in range(input()):
    x1,y1,x2,y2,x3,y3=map(float,raw_input().split(" "))
    if y2==y1 or y3==y1:
        if y2==y1:
            a2=-(x3-x1)/(y3-y1)
            b2=((y3+y1)-a2*(x1+x3))/2.0
            a,b,c,d,e,f=1.0,0.0,(x1+x2)/2.0,-a2,1.0,b2
        else:
            a1=-(x2-x1)/(y2-y1)
            b1=((y2+y1)-a1*(x1+x2))/2.0
            a,b,c,d,e,f=-a1,1.0,b1,1.0,0.0,(x1+x3)/2.0
    else:
        a1=-(x2-x1)/(y2-y1)
        a2=-(x3-x1)/(y3-y1)
        b1=((y2+y1)-a1*(x1+x2))/2.0
        b2=((y3+y1)-a2*(x1+x3))/2.0
        a,b,c,d,e,f=-a1,1.0,b1,-a2,1.0,b2
    py=(a*f-c*d)/(a*e-b*d)
    px=(c*e-f*b)/(a*e-b*d)
    r=math.sqrt((px-x1)**2 + (py-y1)**2)
    print "{0:.3f} {1:.3f} {2:.3f}".format(px,py,r)
import math
a,b = map(int, input().split())
print(a*b//math.gcd(a,b))


### FIXED CODE ###

import fractions
a,b = map(int, input().split())
print(a*b//fractions.gcd(a,b))
import math

r = input()

s = r*r
l = 2.0*r

print(s,l)

### FIXED CODE ###

import math

r = float(input())

s = math.pi * r**2
l = 2.0*math.pi*r

print(s, l)
from collections import deque
n=int(input())
a=list(map(int,input().split()))
A=[a[0]+a[0]<a[1]-a[0]>a[1]]+a+[a[-1]+a[-1]<a[-2]-a[-1]>a[-2]]
valley=0
peak=1
dp=deque()
for i in range(1,n+1):
  if A[i-1]<A[i]>A[i+1]:
    dp.append((i-1,peak))
  elif A[i-1]>A[i]<A[i+1]:
    dp.append((i-1,valley))
l,lf=dp.popleft()
r,rf=dp.popleft()
if lf == peak:
  ans=a[0]
else:
  ans=a[0]*(r+1)
for i in range(1,n-1):
  if r == i:
    t,tf=r,rf
    r,rf=dp.popleft()
    if rf == valley:
      ans+=a[i]*(i-l+1)*(r-i+1)
    else:
      ans+=a[i]
  	l,lf=t,tf
  else:
    if lf == valley:
      ans+=a[i]*(r-i+1)
    else:
      ans+=a[i]*(i-l+1)
print(ans)

### FIXED CODE ###

class BinaryIndexedTree:
    # http://hos.ac/slides/20140319_bit.pdf
    def __init__(self, size):
        """
        :param int size:
        """
        self.bit = [0 for _ in range(size)]
        self.size = size

    def add(self, i, w):
        """
        i番目にwを加える
        :param int i:
        :param int w:
        :return:
        """
        x = i + 1
        while x <= self.size:
            self.bit[x - 1] += w
            x += x & -x
        return

    def sum(self, i):
        """
        [0,i]の合計
        :param int i:
        :return:
        """
        res = 0
        x = i + 1
        while x > 0:
            res += self.bit[x - 1]
            x -= x & -x
        return res

    def search(self, x):
        """
        二分探索。和がx以上となる最小のインデックス(>= 1)を返す
        :param int x:
        :return :
        """
        i = 0
        s = 0
        step = 1 << self.size.bit_length()
        while step:
            if i + step <= self.size and s + self.bit[i + step - 1] < x:
                print(self.bit[i + step - 1], i, step)
                i += step
                s += self.bit[i - 1]
            step >>= 1
        return i

    def __len__(self):
        return self.size
from collections import defaultdict
n=int(input())
a=list(map(int,input().split()))
d=defaultdict(int)
for i in range(n):
  d[a[i]]=i+1
Bit = BinaryIndexedTree(n+1)
ans=0
for i in range(n):
  j=i+1
  i=d[j]
  x=Bit.sum(i)
  ok=i
  ng=-1
  while ok - ng > 1:
    mid=(ok+ng)//2
    if Bit.sum(mid)==x:
      ok=mid
    else:
      ng=mid
  l=ok+1
  ok=i
  ng=n+1
  while ng - ok > 1:
    mid=(ok+ng)//2
    if Bit.sum(mid)==x:
      ok=mid
    else:
      ng=mid
  r=ok
  ans+=j*(i-l+1)*(r-i+1)
  Bit.add(i,1)
print(ans)
import numpy as np
import fractions

N = int(input())
A = np.array([int(i) for i in (input()).split(" ")])

maxA = np.max(A)

if(maxA == np.min(A)):
    print(maxA)
else:
    #check = (np.unique(maxA // np.arange(1,maxA)))[::-1]
    #check = minA // np.arange(1,minA)
    check = np.arange(1,maxA)[::-1]
    for i in check:
        #全てのAに対してiで割り切れるか＝最大公約数
        #iで割り切れた数＝len(A)-1なら，残りの数にiをかけて最大公約数に出来る．
        num = np.sum((A % i>0))
        if(num < 2):
            #j = A[np.where(A % i>0)][0]
            #print(i,j,i*j//math.gcd(i,j))
            #if(i*j//fractions.gcd(i,j) < 10**9):
            print(i)
            break

### FIXED CODE ###

import numpy as np
import fractions

N = int(input())
A = np.array([int(i) for i in (input()).split(" ")])

maxA = np.max(A)


if(maxA == np.min(A)):
    print(maxA)
elif(N==2):
    print(maxA)
else:
    R=np.zeros((N))
    L=np.zeros((N))
    M=np.zeros((N))

    L[0] = 0
    R[N-1] = 0
    for i in range(1,N):
        #0~i-1番目までの最大公約数
        L[i] = fractions.gcd(A[i-1],L[i-1])
        #i~N番
        R[N-1-i] = fractions.gcd(A[N-1-i+1],R[N-1-i+1])

    M[0] = R[0]
    M[-1] = L[-1]
    for i in range(1,N-1):
        M[i] = fractions.gcd(L[i],R[i])

    print("{}".format(int(np.max(M))))
#a,b = map(int,input().split())
s = input()
S =['SUN','MON','TUE','WEB','THU','FRI','SAT']
print(7-S.index(s))


### FIXED CODE ###

#a,b = map(int,input().split())
s = input()
S = ['SUN','MON','TUE','WED','THU','FRI','SAT']
print(7-S.index(s))
# -*- coding: utf-8 -*-
a[] = str(input())
count = 0
if a[0] == "1":
  count += 1
if a[1] == "1":
  count += 1
if a[2] == "1":
  count += 1
print(count)  

### FIXED CODE ###

# -*- coding: utf-8 -*-
a = str(input())
list(a)
count = 0
if a[0] == "1":
  count += 1
if a[1] == "1":
  count += 1
if a[2] == "1":
  count += 1
print(count)
N, K = list(map(int, input().split()))

def c(n, k):
    result = 1
    for i in range(k):
        result *= n - i
    for i in range(k):
        result /= i + 1
    return int(result)

total = 0
for i in range(K):
    ni = c(K-1, i) * c(N-K+1, i+1)
    print(ni % (10 ** 9 + 7))



### FIXED CODE ###

N, K = list(map(int, input().split()))

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


for i in range(K):
    ni = (cmb(K-1, i, mod)) * (cmb(N-K+1, i+1, mod))
    print(ni % mod)
str = input()
S = list(str)

ans = 0
num = 0

for i in range(len(str)):
  if list[i] == "A" or list[i] == "G" or list[i] == "T" or list[i] == "C":
    num = 1
    for j in range(len(str)):
      if list[j] == "A" or list[j] == "G" or list[j] == "T" or list[i] == "C":
        num = num + 1
      else :
        break
  if ans < num :
    ans = num
  num = 0
  
print(ans)

### FIXED CODE ###

str = input()
S = list(str)

ans = 0
num = 0

for i in range(len(S)):
  if S[i] == "A" or S[i] == "G" or S[i] == "T" or S[i] == "C":
    num = 1
    for j in range(i+1,len(S)):
      if S[j] == "A" or S[j] == "G" or S[j] == "T" or S[j] == "C":
        num = num + 1
      else :
        break
  if ans < num :
    ans = num
  num = 0
  
print(ans)
a = list(map(int,input().split()))

bo = True
if a[0]+a[1] < a[2]*2:
    bo = False
if a[3] > a[4]:
    if bo == True:
        if a[2]*2 >= a[0]:
            price = a[2]*a[4]*2 + (a[3]-a[4])*a[0]
        else:
            price = a[2]*a[3]*2
    else:
        price = a[0]*a[3]+a[1]*a[4]
else:
    if bo == True:
        if a[2]*2 >= a[1]:
            price = a[2]*a[3]*2 + (a[4]-a[3])*a[1]
        else:
            price = a[2]*a[4]*2
    else:
        price = a[0]*a[3]+a[1]*a[4]
print(price)

### FIXED CODE ###

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

price = 700
S = input()
for i in S:
    if i == 'o':
        price = price + 100
print(price)
list=[1, 1, 1, 1, 1]
for i in range(1, 7):
  list.append(6**i)
for j in range(1, 7):
  list.append(9**i)
sorted(list, reverse=True)
N=int(input())
count=0
for i in list:
  if i <= N:
    N=N-i
    count+=1
      if N==0:
        print(count)

### FIXED CODE ###

N=int(input())

A=[1]

i = 1
while True:
    if 6**i <= 100000:
        A.append(6**i)
    else:
        break
    i += 1

i = 1
while True:
    if 9**i <= 100000:
        A.append(9**i)
    else:
        break
    i += 1

A.sort()

dp = [N]*(N+1)
dp[0] = 0
for i in range(1, N+1):
    for j in range(len(A)):
        if i - A[j] >= 0:
            dp[i] = min(1+dp[i-A[j]], dp[i])

print(dp[-1])
h, w = map(int, input().split())
hwl = []
for _ in range(h):
    l = list(input())
    hwl.append(l)

for i in range(h):
    for j in range(w):
        if hwl[i][j] == ".":
            cnt = 0
            if i != 0 and j != 0 and hwl[i-1][j-1] == "#":
                cnt += 1
            if i != 0 and hwl[i-1][j] == "#":
                cnt += 1
            if i != 0 and j < w-1 and hwl[i-1][j+1] == "#":
                cnt += 1
            if j != 0 and hwl[i][j-1] == "#":
                cnt += 1
            if hwl[i][j] == "#":
                cnt += 1
            if j < w-1 and hwl[i][j+1] == "#":
                cnt += 1
            if i < h-1 and j != 0 and hwl[i+1][j-1] == "#":
                cnt += 1
            if i < h-1 and hwl[i+1][j] == "#":
                cnt += 1
            if i < h-1 and j < h-1 and hwl[i+1][j+1] == "#":
                cnt += 1
            hwl[i][j] = str(cnt)
    print("".join(hwl[i]))


### FIXED CODE ###

h, w = map(int, input().split())
hwl = []
for _ in range(h):
    l = list(input())
    hwl.append(l)

for i in range(h):
    for j in range(w):
        if hwl[i][j] == ".":
            cnt = 0
            if i != 0 and j != 0 and hwl[i-1][j-1] == "#":
                cnt += 1
            if i != 0 and hwl[i-1][j] == "#":
                cnt += 1
            if i != 0 and j < w-1 and hwl[i-1][j+1] == "#":
                cnt += 1
            if j != 0 and hwl[i][j-1] == "#":
                cnt += 1
            if j < w-1 and hwl[i][j+1] == "#":
                cnt += 1
            if i < h-1 and j != 0 and hwl[i+1][j-1] == "#":
                cnt += 1
            if i < h-1 and hwl[i+1][j] == "#":
                cnt += 1
            if i < h-1 and j < w-1 and hwl[i+1][j+1] == "#":
                cnt += 1
            hwl[i][j] = str(cnt)
    print("".join(hwl[i]))
from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]
b = []
for key,val in Counter(a).items():
    if val >= 2:
        b.append(key)
        if val >= 4:
            b.append(key)

b.sort()

if len(b)>=2:
    x = b.pop()
    y = b.pop()
    ans = x*y
else:
    ans = 0

print(ans)


### FIXED CODE ###

x, a, b = (int(i) for i in input().split())
aa = abs(a-x)
bb = abs(b-x)
if aa > bb:
    print("B")
else:
    print("A")
n,m = map(int,input().split())
#10進数でちょうどn桁
defs = [tuple(map(int,input().split())) for _ in range(m)]

is_empty = False
jouken = {}

for i in range(n):
    #i桁目で条件に重複がないか見る
    dd = list(set([d[1] for d in defs if d[0]-1 == i]))
    if len(dd) > 1:
        is_empty = True
        break
    elif len(dd) == 1:
        jouken[i] = dd[0] #i桁目の数が決まる

num = [0]*n

if n == 1:
    print(jouken[0])
else:
    if 0 in jouken:
        if jouken[0] == 0:
            is_empty = True
        else:
            num[0] = jouken[0]
    else:
        num[0] == 1
    for i in range(1,len(num)):
        if i in jouken:
            num[i] = jouken[i]
        else:
            num[i] = 0

num = [str(i) for i in num]

if is_empty:
    print(-1)
else:
    print(''.join(num))

### FIXED CODE ###

n,m = map(int,input().split())
#10進数でちょうどn桁
defs = [tuple(map(int,input().split())) for _ in range(m)]

is_empty = False
jouken = {}

for i in range(n):
    #i桁目で条件に重複がないか見る
    dd = list(set([d[1] for d in defs if d[0]-1 == i]))
    if len(dd) > 1:
        is_empty = True
        break
    elif len(dd) == 1:
        jouken[i] = dd[0] #i桁目の数が決まる

num = [0]*n

if n == 1:
    if 0 in jouken:
        num[0] = jouken[0]
    else:
        num[0] = 0
else:
    if 0 in jouken:
        if jouken[0] == 0:
            is_empty = True
        else:
            num[0] = jouken[0]
    else:
        num[0] = 1
    for i in range(1,n):
        if i in jouken:
            num[i] = jouken[i]
        else:
            num[i] = 0

num = [str(i) for i in num]

if is_empty:
    print(-1)
else:
    print(''.join(num))
import numpy as np


def resolve():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))

    A = np.zeros((N, N), dtype=int)
    for i in range(M):
        pp, ss = map(int, input().split())
        ss -= 1
        pp -= 1
        A[pp][ss] = H[ss]
        A[ss][pp] = H[pp]

    ans = 0
    for j in range(N):
        if (A[j].max() == 0 or H[j] > A[j].max()):
            ans += 1

    print(A)


resolve()

### FIXED CODE ###

def resolve():
    n, m = map(int, input().split())
    hhh = list(map(int, input().split()))
    nice = [1] * n

    for _ in range(m):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        ha = hhh[a]
        hb = hhh[b]
        if ha <= hb:
            nice[a] = False
        if ha >= hb:
            nice[b] = False

    print(sum(nice))


resolve()
n = int(input())
l = list(map(int, input().split()))
l.sort()
print(l[n//2] - l[n//2  +1])

### FIXED CODE ###

n = int(input())
l = list(map(int, input().split()))
l.sort()
print(abs(l[n//2-1] - l[n//2]))
x, n = map(int, input().split())
a = [int(x) for x in input().split()]
b = [i for i in range(1,101) if i not in a]
b_tmp = list(map(lambda s:abs(s-x), b))
address = b_tmp.index(min(b_tmp))
print(b[address])

### FIXED CODE ###

x, n = map(int, input().split())
a = [int(x) for x in input().split()]
b = [i for i in range(0,102) if i not in a] 
b_tmp = list(map(lambda s:abs(s-x), b)) #b_tmpはbとxの差分のリストをさくせい
address = b_tmp.index(min(b_tmp))
print(b[address])