peterverebics/CodeNet_Python_118 huggingface dataset:
import numpy as np
n, k = input().split(' ')
dds = []
aas = []
for i in range(int(k)):
  dds.append(int(input()))
  aas.append(list(map(lambda x: int(x), input().split(' '))))
  

uni = len(np.unique(np.array(aas).flatten()))

print(int(n) - uni)
n,k = map(int, input().split())
hito = []
for i in range(k):
  d = int(input())
  x = list(map(int, input().split()))
  for j in range(d):
    hito.append(x[j])
a = list(set(hito))
a.sort()
ans = 0
for i in range(len(hito)):
  if hito[i] != i+1:
    ans += 1
print(ans)
n,k = map(int,input().split())

d =[i for i in range(k)]
ans = []

for index in range(k):
  d = int(input())
  ak = [int(x) for x in input().split()]
  ans.extend(ak)

for index in range(n):
  if ans.count(index+1) == 0:
    print(index+1)
import sys
n, k =map(int,input().split())
d = int(input())

for e in sys.stdin:
    l=e

print(n-d)
N, K = map(int, input().split())
 
tmp = [0] * N
 
for i in range(K):
  input()
  for j in map(int, input().split()):
    tmp[j-1] |= 1 
print(sum(tmp))
N, K = map(int, input().split())
list0 = [list(map(int, input().split())) for i in range(2*K)]
listf = list0[1]
count = 0
for i in range(1, K):
  listf = listf + list0[2*i-1]

for i in range(1, N):
  if i not in listf:
    count = count + 1

print(count)
n,k = map(int,input().split())
count = []
for i in range(1,n+1):
    count.append(i)
    
for j in range(k):
    d = int(input())
    A = list(map(int,input().split()))

print(len(set(count)-set(A)))
S = input()



if S == "ABC":
    print("ARC")
else:
    print("ABC")
N, K = map(int, input().split())
A = set()
for i in range(K):
    #d = int(input())
    a = set(map(int, input().split()))
    A=A|a
    
print(N-len(A))
N,K=map(int,input().split())

d=[]
A=[]

U=set(range(1,N))
X=set()

for i in range(K):
    d.append(int(input()))

    S=map(int,input().split())
    for s in S:
        X.add(s)

print(len(U-X))
n, k = map(int, input().split())
s = set()
for _ in range(k):
    d = int(input())
    a = tuple(map(int, input().split()))
    for _a in a:
        s.add(a)

print(n - len(s))
n,k = map(int,input().split())

l=[0]*n

print(l)

for i in range(k):
    d=int(input())
    a=list(map(int,input().split()))
    for j in a:
        l[j-1]+=1

print(l.count(0))
line1 = list(map(int, input().split()))
peple = list(range(line1[0]))
kashi = list(range(line1[1]))


i = 1
while i < len(kashi):

    holder_count = input()
    holder = list(map(int, input().split()))

    for j in holder:

        try:
        	peple.remove(int(j))
        except ValueError:
        	pass
        finally:

            i = i + 1
peple.remove(0)            
print(len(peple))
n,k = map(int, input().split())
a = set()
for i in [0]*k:
    _ = input()
    a.add(map(int, input().split()))
print(n - len(a))
n, k = map(int, input().split())
da = [list(map(int, input().split())) for _ in range(2*k)]
ans = []
for i in range(1,2*k,2):
    ans.append(da[i])
print(n-len(ans[0]))
n,k=map(int, input().split())
S = []
for i in range(k):
    d1 = int(input())
    S.append([])
    S[i].append(list(map(int, input().split())))

ans = [0]*n

for i,s in enumerate(S):
    for d in s:
        ans[int(d[0])-1]+=1

cnt = 0
for i in ans:
    if i == 0:
        cnt+=1
print(cnt)
n,k = map(int,input().split())
for i in range(k):
        m = set(map(int,input().split()))
s = len(m)    
print(n-s)
n, k = map(int, input().split())
a = set()

for _ in range(k):
  d = int(input())
  a.add(map(int, input().split()))

print(n - len(a))
N,K=map(int,input().split())
a=[list(map(int,input().split()))for i in range(2*K)]
sunuke=[]
if N==1:
    print(0)
    exit()
for i in range(2*K-1):
    if i%2==1:
        d=sum(a[i-1])
        for n in range(d):
            sunuke.append(a[i][n])
#print(sunuke)
sunuke=set(sunuke)
print(N-len(sunuke))
import itertools

N, K = map(int, input().split())
i=0
dlist=[]
mlist=[]

while(i<K) :
  d = int(input())
  val = map(int, input().split())
  dlist.append(d)
  mlist.append(val)
  i+=1

j=1
res=0

list=list(itertools.chain.from_iterable(mlist))

while(j<N):
  if(list.count(j)==0):
    res+=1
  j+=1

print(res)
N, K = map(int, input().split())
D = int(input())
print(N - D)
N,K=map(int,input().split())
l = []
for k in range(K):
    a = int(input())
    lis=list(map(int,input().split()))
    l.extend(lis)
for j in range(N):
    if not j+1 in l:
        print(j+1)
N, K = map(int, input().split())
d_list = []
A_list = []
for i in range(K):
    d_list.append(int(input()))
    A_ = list(map(int, input().split()))
    A_list.extend(A_)

K_all = set(A_list)
N_all = set(range(1, N))


no_N = N_all - K_all


print(len(no_N))
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

def LI(): return list(map(int, stdin.readline().split()))
def LS(): return list(stdin.readline())

import itertools
n, k = LI()
s = []
for i in range(k):
    d = int(input())
    a = LI()
    s.append(a)
s = list(itertools.chain.from_iterable(s))
ans = 0
for i in range(1, n):
    if i not in s:
        ans += 1
print(ans)
line1 = input().split()
n = int(line1[0])
k = int(line1[1])
list1 = []
for i in range(k):
  d = input()
  lst = input().split()
  list1 += lst

set1 = set(list1)
print(set1)
nothing = set(str(i+1) for i in range(n)) - set1
print(len(nothing))
N,K = map(int,input().split())
d=[]
A=[]
for i in range(K):
    d.append(int(input()))
    if d[i]!=1:
        A.append(map(int,input().split()))
    else:
        A.append(int(input()))
answer = N-len(set(A))
print(answer)
n, k = map(int, input().split())
ate = set()

for i in range(k):
    d = int(input())
    l = list(map(int, input().split()))
    for x in l:
        ate.add(x)
print(ate)
print(n - len(ate))
n, k = map(int, input().split())
ls = list(range(1, n+1))
for i in range(k):
  d = int(input())
  tmp = list(map(int, input().split()))
  for p in ls:
    if p in tmp:
      ls.remove(p)
print(len(ls))
n, k = map(int, input().split())

N = list(range(1,n +1))
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for p in a:
        try:
            if N.index(p):
                N[N.index(p)] = 0
        except:
            pass

cnt = 0                    
for q in N:
    if q != 0:
        cnt += 1
print(cnt)
n, k = map(int, input().split())
d = int(input())
a = [int(_) for _ in input().split() for i in range(0, k, 2)]
a_set = set(a)
print(n-len(a_set))
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)

# first line
N, K = list(map(int, input().rstrip().split()))

ans = []
try:
    for i in range(N):
        d = input().rstrip()
        _ = input().rstrip()
        ans.append(d)
except:
    pass

print(N - len(set(ans)))
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)

# first line
N, K = list(map(int, input().rstrip().split()))

ans = []
while 1:
    try:
        d = input().rstrip()
        _ = input().rstrip()
        ans.append(d)
    except EOFError:
        break
print(N - len(set(ans)))
n, k = map(int, input().split())
a = [list(map(int, input().split())) for i in range(2*k)]
ans = [0]*n
for i in range(k):
    for j in range(a[i*2][0]):
        s = a[i*2+1][j]
        ans[s-1] += 1
ans = str(ans)
print(ans.count('0'))
N, K = map(int, input().split())
c = 0
n = 1
for i in range(1,K):
  d = int(input())
  List = list(map(int, input().split()))
for I in range(1,N):
  if n in List:
    n = n+1
  else:
    c = c+1
    n = n+1
print(c)
N,K = list(map(int, input('').split(' ')))
D = set()
for i in range(K):
  input('')
  [D.add(j) for j in map(int, input('').split(' '))]
print(K-len(D))
init=input().split()
num=int(init[0])
snacks=int(init[1])
check=[]

for i in range(snacks):
  sNum=int(input())
  if sNum>1:
    whos=input().split()
    for j in range(sNum):
      check.append(whos[j])
  else:
    who=input()
    check.append(who)
    
for i in range(1,num):
  if str(i) not in check:
    print(i-1)
N,K = map(int,input().split())
L = list(range(1,N))
for i in range(K):
  d = int(input())
  A = list(map(int,input().split()))
  for a in A:
    try:
      L.remove(a)
    except ValueError:
      pass
print(len(L))
N, K = map(int, input().split())
for i in range(1,K):
  d = int(input())
  List = list(map(int, input().split()))
c = 0
n = 1
for I in range(1,N):
  if n in List:
    n = n+1
  else:
    c = c+1
    n = n+1
print(c)
N,K=map(int,input().split())

d=0
A=[]
for i in range(K):
    d=int(input())
    A.append(map(int,input().split()))

A=list(set(A))
ans=N

for k in range(1,N+1):
    if k in A:
        ans=ans-1
print(ans)
N,K = map(int,input().split())
d = [0 for _ in range(K)]
A = [[] for _ in range(K)]
for i in range(K):
    d[i] = int(input())
    A[i] = list(map(int,input().split()))
su_list = [i for i in range(1,K+1)]
for i in range(K):
    for j in range(d[i]):
        if A[i][j] in su_list:
            su_list.remove(A[i][j])        
print(len(su_list))
NK = input()
N = int(NK.split()[0]) #すぬけくんの人数
K = int(NK.split()[1]) #お菓子
s = [input() for i in range(K*2)]
m = s[1:2]
q = m[0].split()
output = N - len(q)
print(output)
n, k = map(int, input().split())
d = []
a = ''
for _ in range(k):
    d.append(int(input()))
    a += input()

ans = 0
for i in range(1, n + 1):
    if a.count(str(i)) == 0:
        ans += 1

print(ans)
N,K = (int(x) for x in input().split())
all = set(map(lambda a: a+1,range(N)))
for i in range(K):
	d = input()
	Ai = set(int(x) for x in input().split())
	all -= Ai
	print(Ai)
print(len(all))
N, K = [int(n) for n in input().split()]

sunuke = set(range(1, K+1))
for i in range(K):
    _ = input()
    As = [int(n) for n in input().split()]
    for A in As:
        if A in sunuke:
            sunuke.remove(A)

print(len(sunuke))
n, k = map(int, input().split())
a = [list(map(int, input().split())) for i in range(2*k)]
ans = [0]*n
for i in range(k):
    for j in range(a[i*2][0]):
        s = a[i*2+1][j]
        ans[s-1] += 1
ans = str(ans)
print(a)
print(ans)
print(ans.count('0'))
N, K = map(int, input().split())
#ANSlist = [1]*(N)
ANSlist = []
ANS = 0

for i in range(K):
    I = input() #
    S = list(input())
    for j in range(len(S)):
        if S[j] != " ":
            #ANSlist[int(S[j])-1] = 0
            if not S[j] in ANSlist:
                ANSlist.append(S[j])
                ANS += 1
            


'''for i in range(len(ANSlist)):
    if ANSlist[i] != 0:
        ANS += 1'''

print(N-ANS)
N, M = map(int, input().split())
d = []
for _ in range(M):
    d.append(int(input()))
    A = list(map(int, input().split()))
res = set(d)
ans = N-len(res)
print(ans)
nk = input().split()
n = int(nk[0])
k = int(nk[1])
s = [input() for i in range(k*2)]
o = []

for  j in range(len(s)):
    if j % 2 == 0:
        pass
    else:
        o[len(o):len(o)] = s[j]
        print(o)

l =list(set(o))
ans = n - len(l) 
print(ans)
from collections import defaultdict

N, K = list(map(int, input().split()))
d = defaultdict(list)
for x in range(K):
    input()
    for i in map(int, input().split()):
        d[i].append(True)
count = 0
for i in range(1, K):
    if len(d[i]) == 0:
        count += 1
print(count)
N, K = [int(i) for i in input().split()]
result = []
for i in range(K):
    d = int(input())
    x = [int(i) for i in input().split()]
    for i in x:
        if x not in result:
            result.append(x)

print(N - len(result))
N, K = map(int, input().split())

l = []
i = 0

while i < 2*K:
  i += 1
  if i % 2 == 0:
    l.extend([int(x) for x in input().split()])
  else:
    pass

L = list(set(l))
print(K - len(L))
"""
ある街にN人のすぬけ君(すぬけ君1、すぬけ君2、 ...、 すぬけ君N)が住んでいます。

"""
n, k = map(int, input().split())
n_list = list(range(1, n+1))
input_map = {}
for i in range(k):
    d = int(input())
    d_list = [ int(ai) for ai in input().split()]
    input_map.setdefault(d, d_list)


having_map = {}
for key, value in input_map.items():

    for h in value:
        if n_list.count(h) >= 1:
            n_list.remove(h)

print(len(n_list))
line1 = list(map(int, input().split()))
peple = list(range(line1[0]+1))
kashi = list(range(line1[1]+1))
peple.remove(0)
kashi.remove(0)

i = 1
while i <= kashi[-1]:

    holder_count = input()
    holder = list(map(int, input().split()))

    for j in holder:

        try:
        	peple.remove(int(j))
        except ValueError:
        	pass
        finally:

            i = i + 1

print(len(peple))
n,k = [int(x) for x in input().split(' ')]
 
def solve(n, k):
    snukes = [None] * n
    victims = 0
    
    for i in range(k):
        snacks = int(input())
        snukes_snacks = [int(z) for z in input().split(' ')]
        for j in range(snacks):
            snukes[snukes_snacks[j] - 1] = snukes_snacks[j]
    
    print(snukes)
    for w in range(n):
        if snukes[w] is None:
            victims += 1
    
    print(victims)
 
solve(n, k)
n, k = map(int,input().split())

l = [list(map(int,input().split())) for i in range(k*2)]

ans = 0
for i in range(1,k+1):
    if l[2*i-1].count(i) == 0 :
        ans += 1

print(ans)
init=input().split()
num=int(init[0])
snacks=int(init[1])
check=[]

for i in range(snacks):
  sNum=int(input())
  if sNum>1:
    whos=input().split()
    for j in range(sNum):
      check.append(whos[j])
  else:
    who=input()
    check.append(who)
    
for i in range(1,num):
  if str(i) not in check:
    print(i+1)
N, K = map(int, input().split())
ANSlist = [1]*(N)
print(ANSlist)
for i in range(K):
    I = input() #
    S = list(input())
    for j in range(len(S)):
        if S[j] != " ":
            ANSlist[int(S[j])-1] = 0

ANS = 0

for i in range(N):
    if ANSlist[i] != 0:
        ANS += 1

print(ANS)
N, K = map(int, input().split())
lst = []
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for char in A:
        if char not in lst:
            lst.append(char)
count = 0
for i in range(1, K+1):
    if i not in lst:
        count += 1
print(count)
import itertools
N, K = map(int, input().split())
i=0
dlist=[]
mlist=[]
while(i<K) :
  d = int(input())
  val = map(int, input().split())
  dlist.append(d)
  mlist.append(val)
  i+=1
res=0
list=list(itertools.chain.from_iterable(mlist))
if(N==1):
  if(list.count(1)==0):
    res+=1
else:
  j=1
  while(j<N):
    if(list.count(j)==0):
      res+=1
    j+=1
print(res)
N, K = map(int, input().split())
A = [0] * N

for i in range(K):
    d = int(input())
    targets = list(map(int, input().split()))
    for index in range(d):
        A[index] = 1

count = 0
for i in range(N):
    if A[i] == 0:
        count += 1

print(count)
nk = input().split()
n = int(nk[0])
k = int(nk[1])
s = [input() for i in range(k*2)]
o = []

for  j in range(len(s)):
    if j % 2 ==0:
        o[len(o):len(o)] = s[j]
    else:
        pass

l =list(set(o))
ans = n - len(l) 
print(ans)
N, K = map(int, input().split())
S = [i for i in range(1, K+1)]
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for j in A:
        if j in S:
            S.remove(j)
print(len(S))
N, K = map(int, input().split())
A = []

for i in range(K):
  d = int(input())
  a = list(map(int, input().split()))
  A.append(a)

ref = A[0]

for i in range(1, K):
  ref = list(set(ref) & set(A[i])) + list(set(ref) ^ set(A[i]))

len = len(ref)

print(len)
print(N - len)
N, K = map(int, input().split())
d = [0] * K
A = [0] * K
for i in range (K):
	d[i] = map ( int, input() .split())
	A[i] = list(map(int, input().strip().split())) 

for j in range (K):
    UKE = list ( set(list(range(N))) - set(A[j]) )

print ( len(UKE) )
n, k = map(int, input().split())
d_a = [list(map(int, input().split())) for i in range(2*k)]

l = list()
for i in range(1, k, 2):
    for j in range(d_a[i-1][0]):
        l.append(d_a[i][j])
print(n - len(l))
n, k = map(int, input().split())
ans = [0] * n

for i in range(k):
    d = int(input())
    q = list(map(int, input().split()))
    for j in range(d):
        ans[j - 1] = 1

print(ans.count(0))
N,K=map(int,input().split())
s=set([])
for i in range(K):
  input()
  s=set(input().split())
print(N-len(s))
from collections import Counter
N,K = list(map(int,input().split()))

snk_sweets = []

for i in range(K):
    try:
        sweets = int(input())
        snk_sweets = (list(int(x) for x in input().split()))

    except:
        break;

counter_snk = Counter(snk_sweets)
len_snk = len(counter_snk.keys())
print(N - len_snk)
N,K = map(int,input().split())
N_set = set(range(N))

kari = []
for i in range(2*K):
  if i % 2 == 0:
    pass
  else:
    kari.append([int(i) for i in input().split()])
flatten = lambda x: [z for y in x for z in (flatten(y) if hasattr(y, '__iter__') and not isinstance(y, str) else (y,))]
kari = set(flatten(kari))

sa = N_set - kari
print(len(sa))
n, k = input().split()
sunuke = []

for i in range(0, int(n)):
  sunuke.append(0)

for i in range(0, int(k)):
  okashi = input()
  mochi = list(map(int, input().split()))
  for j in range(0, len(mochi)):
    sunuke[j-1] += 1
    
print(sunuke.count(0))
#--Trick or Treat
import itertools

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

A = []
judge = list(range(1,N+1))
for i in range(K):
  d = int(input())
  A.append([int(i) for i in input().split()])

allocate = list(itertools.chain.from_iterable(A))
#print(judge)
#for i in range(1,K):

l1_l2_sym_diff = []
l1_l2_sym_diff = set(allocate) ^ set(judge)
print(l1_l2_sym_diff)
import fileinput

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

import sys
s = sys.stdin.readlines()
di = dict()
for d in s[0::2]:
    di[d] = True

print(N-len(di.keys()))
n, k = map(int, input().split())
dict = {}

for t in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for i in range(1, n + 1):
        for j in a:
            if j in dict:
                dict[j] += 1
            else:
                dict[i] = 0

res = 0
for v in dict.values():
    if v == 0:
        res += 1
print(res)
import itertools
N1, K1 = map(int, input().split())
listA=[]
while True:
    try:
        listA.append(list(map(int,input().split())))
    except:
        break;
N = len(listA)
listB = []
for n in range(1,N):
  if n%2==0:
    listB.append(listA[n])
listC = list(itertools.chain.from_iterable(listB))
print(N1 - len(list(set(listC))))
n, k = map(int, input().split())
c = 2 * k
ls = [input().split() for _ in range(c)]
i = 1
while i < c:
    l = [j for j in ls[i]]
    i += 2
print(n-len(set(l)))
N, K = map(int, input().split()) 
d = int(input())

print(N-d)
N,K = map(int,input().split())
A = [1]*N
import collections
for i in range(K):
  d = int(input())
  check = input().split()
  for j in range(d):
    if A[int(check[j])-1] == 1:
      A[int(check[j])-1] = 0
c = collections.Counter(A)
print(c[0])
N, K = map(int, input().split())
#print('N : ' + str(N))
#print('K : ' + str(K))
li = [0 for i in range(N)]

for i in range(0,K): 
  d = int(input())
 # print('')
 # print('d : ' + str(d))
  A = list(map(int, input().split()))
  print('<A>')
  for j in A:
  #  print(j)
    li[j-1] = 1
sum = 0
#print(li)

for i in range(0,N):
  if li[i] == 0:
    sum += 1
print(sum)
n, k = map(int, input().split())
a = []
for i in range(1,k+1):
    d = int(input())
    if d == 1:
        a.append(int(input()))
    else:
        a.append(map(int, input().split()))

a = set(a)
print(n - len(a))
import itertools
n,k = map(int,input().split())
ans = 0
l = []
for i in range(k) :
    d = int(input())
    l.append(input().split())

l = list(itertools.chain.from_iterable(l))
l = [int(i) for i in l]

for i in range(k) :
    if not i in l :
        ans += 1
print(ans)
N, K = map(int, input().split())
 
tmp = set()
 
for i in range(K):
  input()
  tmp |= set(input())
 
print(N - len(tmp) - 1)
n, k = map(int, input().split())

array = []

s = 0
for i in range(k):
  d = int(input())
  array += list(map(int, input().strip().split()))

array = set(array)


for j in range(1,n):
  if j not in array:
    s += 1
print(s)
N, K = map(int, input().split())
people = set(range(1, K+1))
for i in range(K):
    d = int(input())
    A = map(int, input().split())
    for a in A:
        people.discard(a)
print(len(people))
init=input().split()
num=int(init[0])
snacks=int(init[1])
check=[]

for i in range(snacks):
  sNum=int(input())
  if sNum>1:
    whos=input().split()
    for j in range(sNum):
      check.append(whos[j])
  else:
    who=input()
    check.append(who)
   
count=0
for i in range(1,num):
  if str(i) not in check:
    count=count+1
print(count)
n,k=map(int,input().split())
L=[list(map(int, input().split())) for i in range(2*k)]
Z=[]
for i in range(1,2*k,2):
  Z.extend(L[i])
x=0
for i in range(1,n):
  if Z.count(i)==0:
    x+=1
  else:
    pass
print(x)
N , K = map(int, input().split())
has = set()
for _ in range(K):
    d = int(input())
    has = set(map(int, input().split()))
print(N - len(has))
a, b = map(int, input().split())
c = int(input())
print(a-c)
N, K = map(int, input().split())
A = []
ans = 0

for i in range(K):
  d = int(input())
  a = list(map(int, input().split()))
  for j in range(d):
    A.append(a[j])

A.sort

for k in range(1, K+1):
  if k in A:
    continue
    
  else:
    ans += 1
        
print(ans)
n,k=map(int,input().split())
ans=[1]*n
for _ in range(k):
    d=int(input())
    li=list(map(int,input().split()))
    for i in li:
        ans[i-1]==0
print(sum(ans))
n, k = map(int, input().split())
hash_list = [False for i in range(n)]

for i in range(k):
    d = int(input())
    okashi_list = list(map(int,input().split()))
    print(okashi_list)
    for j in range(d):
        having = okashi_list[j] - 1
        if not hash_list[having]:
            hash_list[having] = True

count = 0
for i in range(n):
    if not hash_list[i]:
        count += 1
        

print(hash_list)
print(count)
n,k=map(int,input().split())	
x=[list(map(int, input().split())) for i in range(2*k)]
ans=[range(1,n+1)]
num=[]
print(x)
many=x[0:2*k:2]
cookie=x[1:2*k:2]
print(many)
print(cookie)
for y in range(len(cookie)):
    for z in range(len(cookie[y])):
        num.append(cookie[y][z])
Q=set(num)
W=list(Q)
print(n-len(W))
n, m = map(int, input().split())
ql = [tuple(map(int, input().split())) for i in range(2*m)]
a = ql[1::2]
if n <= len(set(a)):
    print(0)
else:
    print(n - len(set(a)))
from collections import Counter
N,K=map(int,input().split())
ans=[0]*N
print(ans)

for i in range(K):
    d=int(input())
    A=list(map(int,input().split()))
    for j in range(d):
        ans[A[j]-1] += 1


ac = Counter(ans)

print(ac[0])
N, K = map(int, input().split())
list0 = [list(map(int, input().split())) for i in range(2*K)]
d = list0[0::2]
listd = list0[1::2]
listf = listd[0]
count = 0
for i in range(1, K):
  listf = listf + listd[i]

for i in range(1, N):
  if i not in listf:
    count = count + 1

print(count)
N, K = map(int, input().split())

d = []
A = []
for i in range(K):
    d_pre = int(input())
    A_pre = [int(x) for x in input().split()]
    d.append(d_pre)
    A.extend(A_pre)

A_unique = list(set(A))

ans = 0

for i in range(1, K+1):
    if i in A_unique:
        pass
    else:
        ans += 1

print(ans)
n, k = map(int,input().split())
list = []
if k ==1:
  d = input()
  #print(i)
  for a in map(int,input().split()):
    list.append(a)
    
else:
  
  for i in range(0,k-1):
    d = input()
    #print(i)
    #for a in map(int,input().split()):
    #  list.append(a)
    list.extend(input().split())
    
#print(list)
print(n - len(set(list)))
n, k = map(int, input().split())
anslist = [0] * (n + 1)
for x in range(k):
    d = int(input())
    list = input()
    for a in range(len(list)):
        if list[a] == ' ': continue
        anslist[int(list[a])] = 1
print(n - sum(anslist))
NK = list(map(int, input().split()))
ans = [0]*NK[0]

for i in range(0,NK[1]):
  d = int(input())
  table  = list(map(int, input().split()))
  for j in range(0,NK[0]):
    if table.count(j) != 0:
      ans[j] = 1
print(NK[1]-sum(ans))
def Qb():
    n, k = map(int, input().split())
    ans = set()
    for v in range(k):
        d = int(input())
        ns = [int(v) for v in input().split()]
        for n in ns:
            ans.add(n)
    print(n - len(ans))


if __name__ == '__main__':
    Qb()
import itertools
n, k = map(int, input().split())
d = []
a = []
n_1=[i for i in range(1,n+1)]
for i in range(k):
    d.append(int(input()))
    a.append(list(map(int,input().split())))
a_1 = list(itertools.chain.from_iterable(a))
c=list(set(n_1)-set(a_1))
for d in c:
  print(d)