n,m=map(int,input().split())
a=[]
k=[]
while True:
    try:
        dk,*d=list(map(int,input().split()))
        a.append(d)
        k.append(dk)
    except:
        break;
ans=set(a[0])
for i in range(1,n):
  ans=ans&set(a[i])

print(len(ans)) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m a=[] a [] k=[] k [] while True:
    try:
        dk,*d=list(map(int,input().split()))
        a.append(d)
        k.append(dk)
    except:
        break; True try:
        dk,*d=list(map(int,input().split()))
        a.append(d)
        k.append(dk)
    except:
        break; except:
        break; break dk,*d=list(map(int,input().split())) dk list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split *d d a.append(d) a.append a append d k.append(dk) k.append k append dk ans=set(a[0]) ans set(a[0]) set a[0] a 0 for i in range(1,n):
  ans=ans&set(a[i]) i range(1,n) range 1 n ans=ans&set(a[i]) ans ans&set(a[i]) ans set(a[i]) set a[i] a i print(len(ans)) print len(ans) len ans ans=ans&set(a[i]) ans&set(a[i]) ans ans=set(a[0]) set(a[0]) ans k=[] [] k a=[] [] a n,m=map(int,input().split()) map(int,input().split()) n m=map(int,input().split()) map(int,input().split()) m dk,*d=list(map(int,input().split())) list(map(int,input().split())) dk
n,m=map(int,input().split())
a=[]
k=[]
while True:
    try:
        dk,*d=list(map(int,input().split()))
        a.append(d)
        k.append(dk)
    except:
        break;
ans=set(a[0])
for i in range(1,n):
  ans=ans&set(a[i])

print(len(ans))