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

s = set([])
for i in range(1,31):
    s.add(i)

for _ in range(n):
    _,*a = list(map(int, input().split()))
    s &= set(a)

print(len(s)) n,m = list(map(int, input().split())) n list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split m s = set([]) s set([]) set [] for i in range(1,31):
    s.add(i) i range(1,31) range 1 31 s.add(i) s.add s add i for _ in range(n):
    _,*a = list(map(int, input().split()))
    s &= set(a) _ range(n) range n _,*a = list(map(int, input().split())) _ list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split *a a s &= set(a) s set(a) set a print(len(s)) print len(s) len s n,m = list(map(int, input().split())) list(map(int, input().split())) n s = set([]) set([]) s m = list(map(int, input().split())) list(map(int, input().split())) m _,*a = list(map(int, input().split())) list(map(int, input().split())) _ s &= set(a) set(a) s
n,m = list(map(int, input().split()))

s = set([])
for i in range(1,31):
    s.add(i)

for _ in range(n):
    _,*a = list(map(int, input().split()))
    s &= set(a)

print(len(s))