N,M=map(int,input().split())
ListMaster=[]
for i in range(M):
  ListMaster.append(i+1)
s =set(ListMaster)
mid = set()
List = []
for i in range(N):
  List.append(list(map(int, input().split())))
for i in range(N):
  List[i].pop(0)
for i in range(N):
  mid = set(List[i])
  s = s&mid
print(len(s)) N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M ListMaster=[] ListMaster [] for i in range(M):
  ListMaster.append(i+1) i range(M) range M ListMaster.append(i+1) ListMaster.append ListMaster append i+1 i 1 s =set(ListMaster) s set(ListMaster) set ListMaster mid = set() mid set() set List = [] List [] for i in range(N):
  List.append(list(map(int, input().split()))) i range(N) range N List.append(list(map(int, input().split()))) List.append List append list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split for i in range(N):
  List[i].pop(0) i range(N) range N List[i].pop(0) [i].pop [i] List i pop 0 for i in range(N):
  mid = set(List[i])
  s = s&mid i range(N) range N mid = set(List[i]) mid set(List[i]) set List[i] List i s = s&mid s s&mid s mid print(len(s)) print len(s) len s mid = set(List[i]) set(List[i]) mid M=map(int,input().split()) map(int,input().split()) M s = s&mid s&mid s mid = set() set() mid List = [] [] List N,M=map(int,input().split()) map(int,input().split()) N ListMaster=[] [] ListMaster s =set(ListMaster) set(ListMaster) s
N,M=map(int,input().split())
ListMaster=[]
for i in range(M):
  ListMaster.append(i+1)
s =set(ListMaster)
mid = set()
List = []
for i in range(N):
  List.append(list(map(int, input().split())))
for i in range(N):
  List[i].pop(0)
for i in range(N):
  mid = set(List[i])
  s = s&mid
print(len(s))