Scanf.scanf "%d %d" (fun n m ->
    let foods = Array.make m 0 in
    for i = 1 to n do
        Scanf.scanf " %d" (fun k ->
            for j = 1 to k do
                Scanf.scanf " %d" (fun a -> foods.(a - 1) <- foods.(a - 1) + 1)
            done
        )
    done;
    Array.fold_left (fun acc v -> if v = n then acc + 1 else acc) 0 foods |> Printf.printf "%d\n"
)