n,m = map(int,input().split())
ans = ['Yes'] * m
for i in range(n):
    k = list(map(int,input().split()))
    k.pop(0)
    for i in range(m):
        if not i + 1 in k:
            ans[i] = 'No'
print(ans.count('Yes')) n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m ans = ['Yes'] * m ans ['Yes'] * m ['Yes'] 'Yes' m for i in range(n):
    k = list(map(int,input().split()))
    k.pop(0)
    for i in range(m):
        if not i + 1 in k:
            ans[i] = 'No' i range(n) range n k = list(map(int,input().split())) k list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split k.pop(0) k.pop k pop 0 for i in range(m):
        if not i + 1 in k:
            ans[i] = 'No' i range(m) range m if not i + 1 in k:
            ans[i] = 'No' not i + 1 in k i + 1 in k i + 1 i 1 k ans[i] = 'No' ans[i] ans i 'No' print(ans.count('Yes')) print ans.count('Yes') ans.count ans count 'Yes' n,m = map(int,input().split()) map(int,input().split()) n k = list(map(int,input().split())) list(map(int,input().split())) k m = map(int,input().split()) map(int,input().split()) m ans = ['Yes'] * m ['Yes'] * m ans
n,m = map(int,input().split())
ans = ['Yes'] * m
for i in range(n):
    k = list(map(int,input().split()))
    k.pop(0)
    for i in range(m):
        if not i + 1 in k:
            ans[i] = 'No'
print(ans.count('Yes'))