N, M = map(int, input().split())

K, *result = map(int, input().split())
result = set(result)
for _ in range(N-1):
    K, *A = map(int, input().split())
    A = set(A)
    result = result & A
    
print(len(result)) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M K, *result = map(int, input().split()) K map(int, input().split()) map int input().split() ().split () input split *result result result = set(result) result set(result) set result for _ in range(N-1):
    K, *A = map(int, input().split())
    A = set(A)
    result = result & A
     _ range(N-1) range N-1 N 1 K, *A = map(int, input().split()) K map(int, input().split()) map int input().split() ().split () input split *A A A = set(A) A set(A) set A result = result & A result result & A result A print(len(result)) print len(result) len result K, *result = map(int, input().split()) map(int, input().split()) K A = set(A) set(A) A M = map(int, input().split()) map(int, input().split()) M result = result & A result & A result N, M = map(int, input().split()) map(int, input().split()) N K, *A = map(int, input().split()) map(int, input().split()) K result = set(result) set(result) result
N, M = map(int, input().split())

K, *result = map(int, input().split())
result = set(result)
for _ in range(N-1):
    K, *A = map(int, input().split())
    A = set(A)
    result = result & A
    
print(len(result))