import bisect
N, K = map(int, input().split())
D = [0] * N
for i in range(K):
    d = int(input())
    for x in input().split():
        x = int(x)
        x -= 1
        D[x] += 1
D.sort()
print(bisect.bisect_left(D, 1))

d59bb3ec5de81b7014836a4c473cf6217b1520dd
<mask token>

<mask token>
for i in range(K):
    d = int(input())
    for x in input().split():
        x = int(x)
        x -= 1
        D[x] += 1
D.sort()
print(bisect.bisect_left(D, 1))

<mask token>
N, K = map(int, input().split())
D = [0] * N
for i in range(K):
    d = int(input())
    for x in input().split():
        x = int(x)
        x -= 1
        D[x] += 1
D.sort()
print(bisect.bisect_left(D, 1))

import bisect
N, K = map(int, input().split())
D = [0] * N
for i in range(K):
    d = int(input())
    for x in input().split():
        x = int(x)
        x -= 1
        D[x] += 1
D.sort()
print(bisect.bisect_left(D, 1))
