CodeEff/ECCO huggingface dataset:
# Original solution

while True:
	try:
		n=int(eval(input()))
		cnt=0
		for a in range(10):
			for b in range(10):
				for c in range(10):
					for d in range(10):
						if a+b+c+d==n:
							cnt+=1
		print(cnt)
	except EOFError:
		break

# Optimized solution

while True:
	try:
		n=int(eval(input()))
		cnt=0
		for a in range(10):
			for b in range(10):
				for c in range(10):
					d = n-(a+b+c)
					if 0<=d<=9:
						cnt+=1
		print(cnt)
	except EOFError:
		break
# Original solution
import itertools
import sys
s=list(range(0,10))
chk=list(itertools.product(s,repeat=4))
for j in sys.stdin:
    ans=0
    for k in chk:
        if sum(k)==int(j):
            ans+=1
    print(ans)

# Optimized solution
while 1:
    try:
        n=int(input())
    except EOFError:
        break
    print(len([1 for i in range(10) for j in range(10) for k in range(10) for l in range(10) if i+j+k+l==n]))
# Original solution
import sys
for e in sys.stdin:
 n=0
 for a in range(10):
  for b in range(10):
   for c in range(10):
    for d in range(10):
     if a+b+c+d==int(e):n+=1
 print(n)


# Optimized solution
import sys
for e in sys.stdin:
 e=int(e);x=list(range(10))
 print((sum([1 for a in x for b in x for c in x for d in x if a+b+c+d==e])))
# Original solution
import sys
for e in sys.stdin:
 e=int(e);x=list(range(10))
 print((sum([1 for a in x for b in x for c in x for d in x if a+b+c+d==e])))


# Optimized solution
import sys
a=[0]*51
for i in range(19):
 a[i]=a[36-i]=(i+3)*(i+2)*(i+1)//6-max(2*(i-9)*(i-8)*(i-7)//3,0)
for e in sys.stdin:
 print((a[int(e)]))
# Original solution
import sys
a=[0]*51;x=list(range(10))
for i in range(51):
 a[i]=sum([1 for p in x for q in x for r in x for s in x if p+q+r+s==i])
for e in sys.stdin:
 print((a[int(e)]))


# Optimized solution
import sys
a=[0]*51
for i in range(10):a[i]=a[36-i]=(i+3)*(i+2)*(i+1)//6
for i in range(10,19):a[i]=a[36-i]=(i+3)*(i+2)*(i+1)//6-a[i-10]*4
for e in map(int,sys.stdin):print((a[e]))
# Original solution
memo = [[None for i in range(51)] for j in range(5)]
memo[0][0] = 1
for i in range(1, 51):
    memo[0][i] = 0


def f(n, sm):
    if memo[n][sm] is not None:
        return memo[n][sm]
    memo[n][sm] = 0
    for i in range(min(10, sm + 1)):
        memo[n][sm] += f(n - 1, sm - i)
    return memo[n][sm]

try:
    while True:
        print(f(4, int(input())))
except:
    pass

# Optimized solution
def mlist(n, *args, **keys):
    if len(args) == 0:
        return [keys.get('default')] * n
    else:
        return [mlist(*args, **keys) for i in range(n)]


def f(n, sm):
            if n == 0:
                return int(sm == 0)
            if memo[n][sm] is not None:
                return memo[n][sm]
            memo[n][sm] = 0
            for i in range(min(10, sm + 1)):
                memo[n][sm] += f(n - 1, sm - i)
            return memo[n][sm]

try:
    memo = mlist(5, 51)
    while True:
        print(f(4, int(input())))
except EOFError:
    pass
# Original solution
import sys
for line in sys.stdin:
    n = int(line)
    count = 0
    for i in range(10):
        for j in range(10):
            for k in range(10):
                for l in range(10):
                    if i + j + k + l == n:
                        count += 1
    print(count)

# Optimized solution
import sys
t = [0 for i in range(10000)]
c = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            for l in range(10):
                t[c] = i + j + k + l
                c += 1
for line in sys.stdin:
    print((t.count(int(line))))
# Original solution
r = range
while True:
    try:
        n = int(eval(input()))
        ans = []
        ans = [(a,b,c,d) for a in r(10) for b in r(10) for c in r(10) for d in r(10) if a+b+c+d==n and (a,b,c,d) not in ans]
        print((len(ans)))
    except:
        break

# Optimized solution
while True:
    try:
        n = int(eval(input()))
    except:
        break
    ans = 0
    for a in range(10):
        for b in range(10):
            for c in range(10):
                d = n - (a + b + c)
                ans += 0 <= d <= 9
    print(ans)
# Original solution
import sys
table={}
def dfs(a,b):
    global table
    if not a in table:
        if a==0:return 1
        elif b==0 or a < 0:return 0
        table[(a,b)]=sum([dfs(a-i,b-1) for i in range(10)])
    return table[(a,b)]
for i in sys.stdin.readlines():
    print(dfs(int(i.strip()),4))

# Optimized solution
import sys
def dfs(a,b):
    if a==0:return 1
    elif b==0 or a < 0:return 0
    return sum([dfs(a-i,b-1) for i in range(10)])
for line in sys.stdin.readlines():
    print(dfs(int(line.strip()),4))
# Original solution
import sys
def dfs(a,b):
    if a==0:return 1
    elif b==0 or a < 0:return 0
    return sum([dfs(a-i,b-1) for i in range(10)])
for line in sys.stdin.readlines():
    print(dfs(int(line.strip()),4))

# Optimized solution
import sys
table={}
def memorize(f):
    global table
    def func(*args):
        if not args in table:
            table[args]=f(*args)
        return table[args]
    return func
@memorize
def dfs(a,b):
    if a==0:return 1
    elif b==0 or a < 0:return 0
    return sum([dfs(a-i,b-1) for i in range(10)])
for i in sys.stdin.readlines():
    print(dfs(int(i.strip()),4))
# Original solution

memo=[[0]*51 for i in range(5)]
def rec(i,n):
    if memo[i][n]!=0:
        return memo[i][n]
    if i==4:
        return 1 if n==0 else 0
    for m in range(10):
        memo[i][n]+=rec(i+1,n-m)
    return memo[i][n]
    
while True:
    try:
        n=int(eval(input()))
        print((rec(0,n)))
    except:
        break

# Optimized solution
memo=[[-1]*51 for i in range(5)]
def rec(i,n):
    if memo[i][n]!=-1:
        return memo[i][n]
    r=0
    if i==4:
        return 1 if n==0 else 0
    for m in range(10):
        r+=rec(i+1,n-m)
    memo[i][n]=r
    return r
     
while True:
    try:
        n=int(eval(input()))
        print((rec(0,n)))
    except:
        break
# Original solution
while True:
	try:
		cnt=0
		i=int(eval(input()))
		for a in range(10):
			for b in range(10):
				for c in range(10):
					for d in range(10):
						if a+b+c+d==i:
							cnt+=1
		print(cnt)
	except:
		break

# Optimized solution
x=[0]*51
for a in range(10):
	for b in range(10):
		for c in range(10):
			for d in range(10):
				x[a+b+c+d]+=1
while True:
	try:
		print((x[int(eval(input()))]))
	except:
		break
# Original solution
import sys,itertools
for n in map(int,sys.stdin):
  x=0
  for num in itertools.product("0123456789",repeat=4):
    eq="{}+{}+{}+{}".format(*(num))
    if eval(eq)==n:x+=1
  print(x)

# Optimized solution
import sys
A=list(range(10))
for n in map(int,sys.stdin):
  x=0
  for a in A:
    d=n-a
    if 0>d or d>27:continue
    for b in A:
      e=d-b
      if 0>e or e>18:continue
      for c in A:
        if (e-c)in A:x+=1
  print(x)
# Original solution
import sys
def f(a,b):
  A=list(range(10))
  if b==1:x=1 if a in A else 0
  else:x=sum([f(a-e,b-1)for e in A])
  return x
for n in map(int,sys.stdin):
  print(f(n,4))

# Optimized solution
import sys
def f(a,b):
  A=list(range(10))
  if b==1:x=1 if a in A else 0
  elif a<0 or a>b*9:x=0
  else:x=sum([f(a-e,b-1)for e in A])
  return x
for n in map(int,sys.stdin):
  print(f(n,4))
# Original solution
import sys
def f(a,b):
  c=b*9-9
  A=list(range(10))
  if b==1:x=1 if a in A else 0
  else:x=sum([f(a-e,b-1)for e in A if 0<=a-e<=c])
  return x
for n in map(int,sys.stdin):print(f(n,4))

# Optimized solution
import sys
def f(a,b,c):
  if b==1:x=1 if 0<=a<=9 else 0
  else:x=sum([f(a-e,b-1,c-9)for e in range(10) if 0<=a-e<=c])
  return x
for n in map(int,sys.stdin):print(f(n,4,3*9))
# Original solution
import sys
from itertools import product

sum = [0] * 51
for k,l in product([i+j for i,j in product(list(range(10)),repeat=2)],repeat=2):
    sum[k+l] += 1

for i in sys.stdin:
    print((sum[int(i)]))

# Optimized solution
import sys
import math

def nCr(n, k):
    if 0 <= k <= n:
        nk,kk = 1,1
        for t in range(1, min(k, n - k) + 1):
            nk = nk*n
            kk = kk*t
            n -= 1
        return nk // kk
    else:
        return 0

p = [0] * 51
v = 0
for i in range(19):
    t = nCr(i+3, i)
    v = v + 4 * nCr(i-8,i-10)
    p[i] = t - v
    p[36-i] = p[i]

for i in sys.stdin:
    print((p[int(i)]))
# Original solution
a = []
for _ in range(5):
    x = int(eval(input()))
    a.append(x if x>= 40 else 40)
print((sum(a)//5))

# Optimized solution
scores = [int(eval(input())) for _ in range(5)]
print((sum([(score < 40) * 40 + (score >= 40) * score for score in scores]) // 5))
# Original solution
from collections import defaultdict as ddic, deque
from itertools import combinations, permutations, product
import sys
sys.setrecursionlimit(10**6)
stdout = sys.stdout
rr = lambda: input().strip()
rri = lambda: int(input())
rrm = lambda: list(map(int, input().strip().split()))


def solve(N, A):
    memo = {}
    def dp(i, color):
        if i == N: return 0
        if (i, color) in memo:
            return memo[i, color]
        if color == 1:  # black
            # no white
            ans = dp(i+1, 1) + (A[i] != color)
        else:
            ans = min(dp(i+1, 0), dp(i+1, 1)) + (A[i] != color)
        memo[i, color] = ans
        return ans

    return min(dp(0, 0), dp(0, 1))
###
N = rri()
S = rr()
A = [1 if c == '#' else 0 for c in S]
print(solve(N, A))


# Optimized solution
from collections import defaultdict as ddic, deque
from itertools import combinations, permutations, product
import sys
sys.setrecursionlimit(10**6)
stdout = sys.stdout
rr = lambda: input().strip()
rri = lambda: int(input())
rrm = lambda: list(map(int, input().strip().split()))


def solve(N, A):
    dp0 = [0] * (N+1)
    dp1 = [0] * (N+1)
    for i in range(N-1, -1, -1):
        for color in (0, 1):
            if color == 1:
                ans = dp1[i+1] + (A[i] != color)
            else:
                ans = min(dp0[i+1], dp1[i+1]) + (A[i] != color)

            if color == 0:
                dp0[i] = ans
            else:
                dp1[i] = ans

    return min(dp0[0], dp1[0])

###
N = rri()
S = rr()
A = [1 if c == '#' else 0 for c in S]
print(solve(N, A))
# Original solution
N, M = list(map(int, input().split()))
a = [sorted(list(map(int, input().split()))[1:]) for _ in range(N)]
b = [i for i in range(1, M + 1)]
c = [i for i in range(1, M + 1)]
for i in range(N):
  for j in range(len(b)):
    if (not b[j] in a[i]) and b[j] in c:
      c.remove(b[j])
print((len(c)))


# Optimized solution
N, M = list(map(int, input().split()))
a = [list(map(int, input().split()))[1:] for _ in range(N)]
b = [i for i in range(1, M + 1)]
c = [i for i in range(1, M + 1)]
for i in range(N):
  for j in range(M):
    if b[j] in c and (not b[j] in a[i]):
      c.remove(b[j])
print((len(c)))
# Original solution
n, m = list(map(int,input().split()))
a = []
for i in range(n):
    a += list(i for i in (list(map(int,input().split() ))))[::-1]
    a.pop(-1)
print((sum([1 if a.count(i) == n else 0 for i in range(m+1)])))

# Optimized solution
n, m = list(map(int,input().split()))
s = set(range(1,m+1))
for i in range(n):
    _,*a = list(map(int,input().split()))
    s &= set(a) # 集合の積
print((len(s)))
# Original solution
N, M = list(map(int, input().split()))
all_dish = []

for n in range(N):
    K_n_list = list(map(int, input().split()))
    del K_n_list[0]
    for K_n_list_num in K_n_list:
        all_dish.append(K_n_list_num)

prefer_dish = []
dish_kind = list(set(all_dish))
prefer_dish = [dish_kind_num for dish_kind_num in dish_kind if all_dish.count(dish_kind_num) == N]

print((len(prefer_dish)))

# Optimized solution
ii=lambda:int(eval(input()))
miis=lambda:list(map(int,input().split()))
lmiis=lambda:list(map(int,input().split()))

n,m=miis()

k=lmiis()
st=set(k[1:])

for i in range(n-1):
  ki=lmiis()
  st=st&set(ki[1:])

print((len(st)))
# Original solution
n, m = list(map(int, input().split()))
res = [[False for _ in range(m)] for _ in range(n)]

for i in range(n):
    o = list(map(int, input().split()))
    for j, x in enumerate(o):
        if j != 0:
            res[i][x - 1] = True

res = list(zip(*res))

ans = sum(1 for x in res if all(x))

print(ans)


# Optimized solution
n, m = list(map(int, input().split()))
res = [0] * m

for i in range(n):
    o = list(map(int, input().split()))
    for j, x in enumerate(o):
        if j != 0:
            res[x - 1] += 1

ans = sum(1 for x in res if x == n)

print(ans)
# Original solution
n,m=list(map(int,input().split()));d=[i+1 for i in range(m)]
def listdup(a,b):
  x=[]
  for i in a:
    if i in b:x.append(i)
  return sorted(x)
for i in range(n):
  a=list(map(int,input().split()));a=a[1:];a.sort()
  d=listdup(a,d)
print((len(d)))

# Optimized solution
n,m=list(map(int,input().split()))
s=set(list(map(int,input().split()))[1:])
for i in range(n-1):
  s&=set(list(map(int,input().split()))[1:])
print((len(s)))
# Original solution
N, M = list(map(int, input().split()))
cnt = [0] * M
for _ in range(N):
    K, *A = list(map(int, input().split()))
    for a in A:
        cnt[a - 1] += 1
print((sum(c == N for c in cnt)))

# Optimized solution
n, m = list(map(int, input().split()))
cnt = [0] * m
for _ in range(n):
    k, *A, = list(map(int, input().split()))
    for a in A:
        cnt[a - 1] += 1
print((sum(c == n for c in cnt)))
# Original solution
N,M = list(map(int, input().split()))
A = [0 for i in range(M+1)]
for i in range(N):
    tmp = input().split()
    for j in tmp[1:]:
        A[int(j)] += 1
ans = len([0 for i in A if i == N])
print(ans)
    

# Optimized solution
n,m = list(map(int, input().split()))
d = {}
for _ in range(n):
  k = input().split()
  for j in k[1:]:
    if j not in d:
      d[j] = 0
    d[j] += 1
print((len([v for v in list(d.values()) if v == n])))
# Original solution
n, m = list(map(int, input().split()))
count = 0
kind = [0 for i in range(m)]
for i in range(n):
    anketo = list(map(int, input().split()))
    for j in range(1, len(anketo)):
        kind[anketo[j]-1] += 1
for i in kind:
    if i == n:
        count += 1
print(count)


# Optimized solution
n, m = list(map(int, input().split()))
c = list(map(int, input().split()))
A = set(c[1:])
for i in range(n-1):
	t = list(map(int, input().split()))
	A &= set((t[1:]))
print((len(A)))
# Original solution
N, M = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]

A = [flatten for inner in A for flatten in inner[1:]]
#print(A)
import collections
A_cnt = collections.Counter(A)
print((sum([l[1]==N for l in A_cnt.most_common()])))


# Optimized solution
N,M = list(map(int,input().split()))
_, *A = list(map(int,input().split()))
s = set(A)
for i in range(N-1):
    _, *B = list(map(int,input().split()))
    s &= set(B)
print((len(s)))
# Original solution
n,m=list(map(int,input().split()))
a=[0]*m
b=[list(map(int,input().split())) for _ in range(n) ]
      
for i in range(n):
  c=b[i][0]
  for j in range(1,c+1):
    a[b[i][j]-1]+=1

print((a.count(n)))

# Optimized solution
n,m=list(map(int,input().split()))
c=set(range(1,m+1))
for i in range(n):
  a=list(map(int,input().split()))
  b=set(a[1:])
  c=b&c
print((len(c)))
# Original solution
q=set(map(str,list(range(31))))
for s in open(0).readlines()[1:]:
    t=set(s.split()[1:])
    q&=t
print((len(q)))

# Optimized solution
a,b=list(map(int,input().split()))
for i in range(a):
    n,*a=list(map(int,input().split()))
    if i==0:
        l=a
    else:
        l=set(a)&set(l)
print((len(l)))
# Original solution
a,b=list(map(int,input().split()))
for i in range(a):
    n,*a=list(map(int,input().split()))
    if i==0:
        l=a
    else:
        l=set(a)&set(l)
print((len(l)))

# Optimized solution
a,b=list(map(int,input().split()))
for i in range(a):
    if i==0:
        x=set(input().split()[1:])
    else:
        x=x&set(input().split()[1:])
print((len(x)))
# Original solution
def read():
    return int(eval(input()))

def reads():
    return list(map(int, input().split()))

n,m = reads()
a = []
r = []
for i in range(n):
    a.append(reads())
for i in range(n):
    for j in range(1,a[i][0]+1):
        r.append(a[i][j])
ans = 0
for i in set(r):
    if r.count(i) == n:
        ans += 1
print(ans)

# Optimized solution
def read():
    return int(eval(input()))

def reads():
    return list(map(int, input().split()))

n, m = reads()
a = set(input().split()[1:])
for _ in range(n - 1):
  a &= set(input().split()[1:])
print((len(a)))
# Original solution
n, m = list(map(int, input().split()))
k = [list(map(int, input().split())) for i in range(n)]
ans = 0
for i in range(1, m+1):
    cnt = 0
    for p in k:
        if i in p[1:]:
            cnt += 1
    if cnt == n:
        ans += 1
print(ans)

# Optimized solution
n,m = list(map(int,input().split()))
cnt = [0]*(m+1)
for i in range(n):
    x = list(map(int, input().split()))
    for p in x[1:]:
        cnt[p] += 1
print((cnt.count(n)))
# Original solution
import sys
import collections as c

input = sys.stdin.readline

def main():
    ans = 0
    N, M = list(map(int, input().split()))
    a = []
    for _ in range(N):
        a += list(map(int, input().split()))[1:]
    co = c.Counter(a)
    for k, v in list(co.items()):
        if v == N:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

# Optimized solution
import sys

input = sys.stdin.readline

def main():
    ans = 0
    N, M = list(map(int, input().split()))
    f = set(range(1,M+1))
    for _ in range(N):
        a = set(list(map(int, input().split()))[1:])
        f.intersection_update(a)
    print((len(f)))

if __name__ == '__main__':
    main()
# Original solution
N,M=list(map(int,input().split()))
C = set(list(range(1,M+1)))
for _ in range(N):
    L=list(map(int,input().split()))
    A=L[1:]
    C=C&set(A)
print((len(C)))

# Optimized solution
N,M=list(map(int,input().split()))
K=[0]*M
a=0
for i in range(N):
  A=list(map(int,input().split()))
  for j in A[1:]:
    K[j-1]+=1
for i in K:
  if i==N:
    a+=1
print(a)
# Original solution
a,b=list(map(int,input().split()))
c=list(map(int,input().split()))[1:]
#print(c)
for _ in range(a-1):
  #print(range(a))
  d=list(map(int,input().split()))[1:]
  #print(d)
  c=set(c)&set(d)

#print(c)
print((len(c)))

# Optimized solution
a,b=list(map(int,input().split()))
c=list(map(int,input().split()))[1:]
for _ in range(a-1):c=set(c)&set(list(map(int,input().split()))[1:])
print((len(c)))
# Original solution

import collections

N, M = list(map(int, input().split()))
likes = []
for i in range(N):
    x = list(map(int, input().split()))
    _ = x.pop(0)
    likes += x

col = collections.Counter(likes)
count = 0
for k, v in list(col.items()):
    if v == N:
        count += 1

print(count)

# Optimized solution

n, m = list(map(int, input().split()))
likes = [0] *  m

for i in range(n):
    k, *a = list(map(int, input().split()))
    for j in a:
        likes[j-1] += 1

count = 0
for i in likes:
    if i == n:
        count += 1

print(count)
# Original solution
N,M = list(map(int,input().split()))
nes = []
count = 0
for i in range(N) :
    li = list(map(int,input().split()))
    nes.append(li)
favorite = [0] * M
for i in range(N) :
    for j in range(1,nes[i][0]+1) :
        favorite[nes[i][j]-1] += 1
for i in range(M) :
    if favorite[i] == N :
        count+=1
print(count)

# Optimized solution
#template
def inputlist(): return [int(k) for k in input().split()]
#template
N,M = inputlist()
ans = [0]*(M+1)
c =0
for i in range(N):
    A = inputlist()
    K = A[0]
    Aa = A[1:]
    for j in range(K):
        ans[Aa[j]] +=1
for i in range(1,M+1):
    if ans[i] == N:
        c+=1
print(c)
# Original solution
from collections import Counter

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

L = []
cnt = 0

for _ in range(n):
    tmp = input().split()
    a = tmp[1:]
    L.extend(a)
    
c = Counter(L)
for k, v in list(c.items()):
    if v==n:
        cnt += 1
print(cnt)

# Optimized solution
n, m = list(map(int, input().split()))
foods = [0] * m
for _ in range(n):
    k, *a = input().split()
    for food in a:
        foods[int(food)-1] += 1
        
print((foods.count(n)))
# Original solution
import functools
print((len(functools.reduce(lambda x, y: x&y,[set(input().split()[1:]) for _ in [0]*int(input().split()[0])]))))

# Optimized solution
print((len(set.intersection(*[set(input().split()[1:]) for _ in [0]*int(input().split()[0])]))))
# Original solution
from functools import reduce
N, M = list(map(int, input().split()))
prod = set(range(1, M + 1))
for _ in range(N):
    prod &= set(list(map(int, input().split()))[1:])
ans = len(prod)
print(ans)

# Optimized solution
# 入力
N, M = list(map(int, input().split()))
K, A = list(zip(*(
    (int(t[0]), list(map(int, t[1].split())))
    for t in (input().split(maxsplit=1) for _ in range(N))
)))

# 素直にカウント
ans = sum(
    all(k in a for a in A)
    for k in range(1, M + 1)
)

# 出力
print(ans)
# Original solution
from functools import reduce

n, m = list(map(int, input().split()))
k = [list(map(int, input().split()))[1:] for _ in range(n)]

print((len(reduce(lambda a,b: a&b, [set(kk) for kk in k]))))


# Optimized solution
n, m = list(map(int, input().split()))

s = [0] * m

for i in range(n):
    a = list(map(int, input().split()))[1:]
    for x in a:
        s[x-1] += 1

ans = 0
for x in s:
    if x == n:
        ans += 1
print(ans)
# Original solution
Tmp = []
Tmp = input().rstrip().split(' ')

nN = int(Tmp[0])
nM = int(Tmp[1])

nData = [[ 0 for i in range(2)] for j in range(nM)]

for i in range(nM):
    nData[i][0]=i+1

for i in range(nN):
	Tmp = input().rstrip().split(' ')
	nK = int(Tmp[0])
	nTmp =[ 0 for j in range(nK)]
	for j in range(nK):
		nTmp[j] = int(Tmp[j+1])
#	print(nTmp)
	for j in range(nM):
		if nData[j][0]  in nTmp:
			nData[j][1] += 1

nAns=0
for i in range(nM):    
    if nData[i][1]==nN:
        nAns += 1

print(nAns)
            
    
    
    

# Optimized solution
mp = []
Tmp = input().rstrip().split(' ')
 
nN = int(Tmp[0])
nM = int(Tmp[1])
 
nF = [ 0 for i in range(nM)]
 
for i in range(nN):
  Tmp = input().rstrip().split(' ')
  nTmpN = int(Tmp[0])
  for j in range(nTmpN):
    nCnt = int(Tmp[j+1]) - 1
    nF[nCnt] += 1

nAns = 0
for i in range(nM):
  nTmpN = nF[i]
  if nTmpN == nN:
    nAns += 1

print(nAns)
# Original solution
from collections import Counter
n, m = list(map(int, input().split()))
food_arr = []
total = 0
for i in range(n):
   food_arr += list(map(int, input().split()[1:]))
    
counter = Counter(food_arr)
for key, value in list(counter.items()):
  if value == n:
    total += 1
print(total)     

# Optimized solution
N, M = list(map(int, input().split()))
se = set(range(1,M+1))
for _ in range(N):
  k, *A = list(map(int, input().split()))
  se &= set(A)
  
print((len(se)))