N,M=map(int,input().split())
l=[0]*M
for i in range(N):
    A=list(map(int,input().split()))
    K=A[0]
    A=A[1:]
    for j in range(K):
        l[A[j]-1]+=1
print(l.count(N)) N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M l=[0]*M l [0]*M [0] 0 M for i in range(N):
    A=list(map(int,input().split()))
    K=A[0]
    A=A[1:]
    for j in range(K):
        l[A[j]-1]+=1 i 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 K=A[0] K A[0] A 0 A=A[1:] A A[1:] A 1: 1 for j in range(K):
        l[A[j]-1]+=1 j range(K) range K l[A[j]-1]+=1 l[A[j]-1] l A[j]-1 A[j] A j 1 1 print(l.count(N)) print l.count(N) l.count l count N l=[0]*M [0]*M l N,M=map(int,input().split()) map(int,input().split()) N K=A[0] A[0] K A=A[1:] A[1:] A M=map(int,input().split()) map(int,input().split()) M A=list(map(int,input().split())) list(map(int,input().split())) A
N,M=map(int,input().split())
l=[0]*M
for i in range(N):
    A=list(map(int,input().split()))
    K=A[0]
    A=A[1:]
    for j in range(K):
        l[A[j]-1]+=1
print(l.count(N))