n,m = map(int, input().split())

s = 0
for i in range(1,m+1):
    s |= 1 << i


for i in range(n):
    a = map(int, input().split())
    a = list(a)
    t = 0
    for j in range(1, len(a)):
        t |= 1 << a[j]
    s &= t


ans = 0
for i in range(1,m+1):
    if (s & (1<<i)) != 0:
        ans += 1

print(ans) n,m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m s = 0 s 0 for i in range(1,m+1):
    s |= 1 << i i range(1,m+1) range 1 m+1 m 1 s |= 1 << i s 1 << i 1 i for i in range(n):
    a = map(int, input().split())
    a = list(a)
    t = 0
    for j in range(1, len(a)):
        t |= 1 << a[j]
    s &= t i range(n) range n a = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split a = list(a) a list(a) list a t = 0 t 0 for j in range(1, len(a)):
        t |= 1 << a[j]
     j range(1, len(a)) range 1 len(a) len a t |= 1 << a[j] t 1 << a[j] 1 a[j] a j s &= t s t ans = 0 ans 0 for i in range(1,m+1):
    if (s & (1<<i)) != 0:
        ans += 1 i range(1,m+1) range 1 m+1 m 1 if (s & (1<<i)) != 0:
        ans += 1 (s & (1<<i)) != 0 s & (1<<i) s 1<<i 1 i 0 ans += 1 ans 1 print(ans) print ans m = map(int, input().split()) map(int, input().split()) m t |= 1 << a[j] 1 << a[j] t s |= 1 << i 1 << i s ans += 1 1 ans a = list(a) list(a) a t = 0 0 t n,m = map(int, input().split()) map(int, input().split()) n a = map(int, input().split()) map(int, input().split()) a ans = 0 0 ans s &= t t s s = 0 0 s
n,m = map(int, input().split())

s = 0
for i in range(1,m+1):
    s |= 1 << i


for i in range(n):
    a = map(int, input().split())
    a = list(a)
    t = 0
    for j in range(1, len(a)):
        t |= 1 << a[j]
    s &= t


ans = 0
for i in range(1,m+1):
    if (s & (1<<i)) != 0:
        ans += 1

print(ans)
