Problem: Katsusando loves omelette rice.  Besides, he loves crème brûlée, tenderloin steak and so on, and believes that these foods are all loved by everyone.  To prove that hypothesis, he conducted a survey on M kinds of foods and asked N people whether they like these foods or not.  The i-th person answered that he/she only likes the A_{i1}-th, A_{i2}-th, ..., A_{iK_i}-th food.  Find the number of the foods liked by all the N people.

Submission attempts (in order):
N,M = map(int,input().split())
a=[]
for i in range(N):
  x = input().split()
  y = int(x[0])
  z = x[1:y+1]
  w = list(map(int(z)))
  w.append(a)
b = []
for l in range(1:M+1):
  for j in range(N-1):
    if l in a[j] and l in a[j+1]:
      l.append(b)
    else:
      b = b
cnt=0
for k in range(1:M+1):
  n = b.count(k)
  if n==N-1:
    cnt +=1
print(cnt)
    
  
    
    
       
    


N,M = map(int,input().split())
a=[]
for i in range(N):
  x = input().split()
  y = int(x[0])
  z = x[1:y+1]
  w = list(map(int,z))
  w.append(a)
b = []
for l in range(1:M+1):
  for j in range(N-1):
    if l in a[j] and l in a[j+1]:
      l.append(b)
    else:
      b = b
cnt=0
for k in range(1:M+1):
  n = b.count(k)
  if n==N-1:
    cnt +=1
print(cnt)
    
  
    
    
       
    


N,M = map(int,input().split())
a=[]
for i in range(N):
  x = input().split()
  y = int(x[0])
  z = x[1:y+1]
  w = list(map(int,z))
  a.append(w)
b = []
for l in range(1:M+1):
  for j in range(N-1):
    if l in a[j] and l in a[j+1]:
      b.append(l)
    else:
      b = b
cnt=0
for k in range(1:M+1):
  n = b.count(k)
  if n==N-1:
    cnt +=1
  else:
    cnt = cnt
print(cnt)
    
  
    
    
       
    


N,M = map(int,input().split())
a=[]
for i in range(N):
  x = input().split()
  y = int(x[0])
  z = x[1:y+1]
  w = list(map(int,z))
  a.append(w)
b = []
for l in range(1:M+1):
  for j in range(N-1):
    if l in a[j] and l in a[j+1]:
      b.append(l)
    else:
      b = b
cnt=0
for k in range(1:M+1):
  n = b.count(k)
  if n==N-1:
    cnt +=1
print(cnt)
    
  
    
    
       
    


N,M = map(int,input().split())
a=[]
for i in range(N):
  x = input().split()
  y = int(x[0])
  z = x[1:y]
  w = list(map(int(z)))
  w.append(a)
b = []
for l in range(1:M+1):
  for j in range(N-1):
    if l in a[j] and l in a[j+1]:
      l.append(b)
    else:
      b = b
cnt=0
k=1
for k in range(M+1):
  n = b.count(k)
  if n==M:
    cnt +=1
print(cnt)
    
  
    
    
       
    

N,M = map(int,input().split())
a=[]
for i in range(N):
  x = input().split()
  z = x[1:]
  w = list(map(int,z))
  a.append(w)
b = []
for l in range(1:M+1):
  for j in range(N-1):
    if ((l in a[j]) and (l in a[j+1])):
      b.append(l)
cnt=0
for k in range(1:M+1):
  n = b.count(k)
  if n==N-1:
    cnt +=1
print(cnt)
    
  
    
    
       
    


N,M = map(int,input().split())
a=[]
for i in range(N):
  x = input().split()
  z = x[1:]
  a += list(map(int,z))
cnt=0
for k in range(1:M+1):
  n = a.count(k)
  if n==N:
    cnt +=1
  else:
    cnt = cnt
print(cnt)
    
  
    
    
       
    


N,M = map(int,input().split())
a=[]
for i in range(N):
  x = input().split()
  y = int(x[0])
  z = x[1:y+1]
  w = list(map(int,z))
  a.append(w)
  
b = []
for l in range(1:M+1):
  for j in range(N-1):
    if ((l in a[j]) and (l in a[j+1])):
      b.append(l)
    else:
      b = b

cnt=0
for k in range(1:M+1):
  n = b.count(k)
  if n==N-1:
    cnt +=1
  else:
    cnt = cnt
print(cnt)
    
  
    
    
       
    


N,M = map(int,input().split())
a=[]
for i in range(N):
  x = input().split()
  y = int(x[0])
  z = x[1:y+1]
  w = list(map(int,z))
  a.append(w)
b = []
for l in range(1:M+1):
  for j in range(N-1):
    if ((l in a[j]) and (l in a[j+1])):
      b.append(l)
    else:
      b = b
cnt=0
for k in range(1:M+1):
  n = b.count(k)
  if n==N-1:
    cnt +=1
  else:
    cnt = cnt
print(cnt)
    
  
    
    
       
    


N,M = map(int,input().split())
a=[]
for i in range(N):
  x = input().split()
  z = x[1:]
  a += list(map(int,z))
cnt=0
for k in range(1:M+1):
  n = a.count(k)
  if n==N:
    cnt +=1
print(cnt)
    
  
    
    
       
    


N,M = map(int,input().split())
a=[]
for i in range(N):
  x = input().split()
  z = x[1:]
  a += list(map(int,z))
cnt=0
for k in range(1,M+1):
  n = a.count(k)
  if n==N:
    cnt +=1
  else:
    cnt = cnt
print(cnt)
    
  
    
    
       
    


Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted