n,m = map(int,input().split())
kl,al = [],[]
for _ in range(n):
	k,*a = list(map(int,input().split()))
	kl.append(k)
	al.append(a)
ans = [0]*(m+1)
cnt = 0
for i in range(n):
	for j in range(kl[i]):
		inx = al[i][j]
		ans[inx] += 1
for t in range(m+1):
	if ans[t] == n:
		cnt += 1
print(cnt) n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m kl,al = [],[] kl [] al [] for _ in range(n):
	k,*a = list(map(int,input().split()))
	kl.append(k)
	al.append(a) _ range(n) range n k,*a = list(map(int,input().split())) k list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split *a a kl.append(k) kl.append kl append k al.append(a) al.append al append a ans = [0]*(m+1) ans [0]*(m+1) [0] 0 m+1 m 1 cnt = 0 cnt 0 for i in range(n):
	for j in range(kl[i]):
		inx = al[i][j]
		ans[inx] += 1 i range(n) range n for j in range(kl[i]):
		inx = al[i][j]
		ans[inx] += 1 j range(kl[i]) range kl[i] kl i inx = al[i][j] inx al[i][j] [i] al i j ans[inx] += 1 ans[inx] ans inx 1 for t in range(m+1):
	if ans[t] == n:
		cnt += 1 t range(m+1) range m+1 m 1 if ans[t] == n:
		cnt += 1 ans[t] == n ans[t] ans t n cnt += 1 cnt 1 print(cnt) print cnt ans = [0]*(m+1) [0]*(m+1) ans inx = al[i][j] al[i][j] inx cnt += 1 1 cnt cnt = 0 0 cnt kl,al = [],[] [] kl al = [],[] [] al n,m = map(int,input().split()) map(int,input().split()) n m = map(int,input().split()) map(int,input().split()) m k,*a = list(map(int,input().split())) list(map(int,input().split())) k
n,m = map(int,input().split())
kl,al = [],[]
for _ in range(n):
	k,*a = list(map(int,input().split()))
	kl.append(k)
	al.append(a)
ans = [0]*(m+1)
cnt = 0
for i in range(n):
	for j in range(kl[i]):
		inx = al[i][j]
		ans[inx] += 1
for t in range(m+1):
	if ans[t] == n:
		cnt += 1
print(cnt)