n,m = map(int,input().split())
like = set(range(1,m+1))
for _ in range(n):
    a = list(map(int,input().split()))
    like = like & set(a[1:])

print(len(like)) n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m like = set(range(1,m+1)) like set(range(1,m+1)) set range(1,m+1) range 1 m+1 m 1 for _ in range(n):
    a = list(map(int,input().split()))
    like = like & set(a[1:]) _ range(n) range n a = list(map(int,input().split())) a list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split like = like & set(a[1:]) like like & set(a[1:]) like set(a[1:]) set a[1:] a 1: 1 print(len(like)) print len(like) len like m = map(int,input().split()) map(int,input().split()) m a = list(map(int,input().split())) list(map(int,input().split())) a like = set(range(1,m+1)) set(range(1,m+1)) like like = like & set(a[1:]) like & set(a[1:]) like n,m = map(int,input().split()) map(int,input().split()) n
n,m = map(int,input().split())
like = set(range(1,m+1))
for _ in range(n):
    a = list(map(int,input().split()))
    like = like & set(a[1:])

print(len(like))