from collections import Counter
n,m = map(int, input().split())
ka = []
for i in range(n):
    ka1 = list(map(int, input().split()))
    ka += ka1[1:]
ka = Counter(ka).most_common()
num = 0
for h in range(len(ka)):
    if ka[h][1] == n:
        num += 1
    else:
        break
print(num) from collections import Counter n,m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m ka = [] ka [] for i in range(n):
    ka1 = list(map(int, input().split()))
    ka += ka1[1:] i range(n) range n ka1 = list(map(int, input().split())) ka1 list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split ka += ka1[1:] ka ka1[1:] ka1 1: 1 ka = Counter(ka).most_common() ka Counter(ka).most_common() (ka).most_common (ka) Counter ka most_common num = 0 num 0 for h in range(len(ka)):
    if ka[h][1] == n:
        num += 1
    else:
        break h range(len(ka)) range len(ka) len ka if ka[h][1] == n:
        num += 1
    else:
        break ka[h][1] == n ka[h][1] [h] ka h 1 n num += 1 num 1 break print(num) print num ka1 = list(map(int, input().split())) list(map(int, input().split())) ka1 m = map(int, input().split()) map(int, input().split()) m num = 0 0 num ka = [] [] ka n,m = map(int, input().split()) map(int, input().split()) n ka = Counter(ka).most_common() Counter(ka).most_common() ka num += 1 1 num ka += ka1[1:] ka1[1:] ka
from collections import Counter
n,m = map(int, input().split())
ka = []
for i in range(n):
    ka1 = list(map(int, input().split()))
    ka += ka1[1:]
ka = Counter(ka).most_common()
num = 0
for h in range(len(ka)):
    if ka[h][1] == n:
        num += 1
    else:
        break
print(num)