import java.util.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                int m = sc.nextInt();
                int[] k = new int[n];
                int[] like = new int[m];
                Arrays.fill(like , 1);
                int[] yono = new int[m];
                for(int i = 0 ; i < n ; i++){
                        k[i] = sc.nextInt();
                        Arrays.fill(yono , 0);
                        for(int j = 0 ; j < k[i] ; j++){
                                yono[sc.nextInt() - 1]++;
                        }
                        for(int ii = 0 ; ii < m ; ii++){
                                like[ii] *= yono[ii];
                        }
                }
                for(int i = 0 ; i < m ; i++){
                        if(i != 0){
                                like[0] += like[i];
                        }
                }
                System.out.println(like[0]);
        }
}//0=48
//鶏になれ import java.util.*; util.* java public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                int m = sc.nextInt();
                int[] k = new int[n];
                int[] like = new int[m];
                Arrays.fill(like , 1);
                int[] yono = new int[m];
                for(int i = 0 ; i < n ; i++){
                        k[i] = sc.nextInt();
                        Arrays.fill(yono , 0);
                        for(int j = 0 ; j < k[i] ; j++){
                                yono[sc.nextInt() - 1]++;
                        }
                        for(int ii = 0 ; ii < m ; ii++){
                                like[ii] *= yono[ii];
                        }
                }
                for(int i = 0 ; i < m ; i++){
                        if(i != 0){
                                like[0] += like[i];
                        }
                }
                System.out.println(like[0]);
        }
}//0=48 Main public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                int m = sc.nextInt();
                int[] k = new int[n];
                int[] like = new int[m];
                Arrays.fill(like , 1);
                int[] yono = new int[m];
                for(int i = 0 ; i < n ; i++){
                        k[i] = sc.nextInt();
                        Arrays.fill(yono , 0);
                        for(int j = 0 ; j < k[i] ; j++){
                                yono[sc.nextInt() - 1]++;
                        }
                        for(int ii = 0 ; ii < m ; ii++){
                                like[ii] *= yono[ii];
                        }
                }
                for(int i = 0 ; i < m ; i++){
                        if(i != 0){
                                like[0] += like[i];
                        }
                }
                System.out.println(like[0]);
        } main {
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                int m = sc.nextInt();
                int[] k = new int[n];
                int[] like = new int[m];
                Arrays.fill(like , 1);
                int[] yono = new int[m];
                for(int i = 0 ; i < n ; i++){
                        k[i] = sc.nextInt();
                        Arrays.fill(yono , 0);
                        for(int j = 0 ; j < k[i] ; j++){
                                yono[sc.nextInt() - 1]++;
                        }
                        for(int ii = 0 ; ii < m ; ii++){
                                like[ii] *= yono[ii];
                        }
                }
                for(int i = 0 ; i < m ; i++){
                        if(i != 0){
                                like[0] += like[i];
                        }
                }
                System.out.println(like[0]);
        } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc int[] k = new int[n]; k new int[n] n int[] like = new int[m]; like new int[m] m Arrays.fill(like , 1) Arrays.fill Arrays like 1 int[] yono = new int[m]; yono new int[m] m for(int i = 0 ; i < n ; i++){
                        k[i] = sc.nextInt();
                        Arrays.fill(yono , 0);
                        for(int j = 0 ; j < k[i] ; j++){
                                yono[sc.nextInt() - 1]++;
                        }
                        for(int ii = 0 ; ii < m ; ii++){
                                like[ii] *= yono[ii];
                        }
                } int i = 0 ; int i = 0 ; i 0 i < n i n i++ i++ i {
                        k[i] = sc.nextInt();
                        Arrays.fill(yono , 0);
                        for(int j = 0 ; j < k[i] ; j++){
                                yono[sc.nextInt() - 1]++;
                        }
                        for(int ii = 0 ; ii < m ; ii++){
                                like[ii] *= yono[ii];
                        }
                } {
                        k[i] = sc.nextInt();
                        Arrays.fill(yono , 0);
                        for(int j = 0 ; j < k[i] ; j++){
                                yono[sc.nextInt() - 1]++;
                        }
                        for(int ii = 0 ; ii < m ; ii++){
                                like[ii] *= yono[ii];
                        }
                } k[i] = sc.nextInt() k[i] k i sc.nextInt() sc.nextInt sc Arrays.fill(yono , 0) Arrays.fill Arrays yono 0 for(int j = 0 ; j < k[i] ; j++){
                                yono[sc.nextInt() - 1]++;
                        } int j = 0 ; int j = 0 ; j 0 j < k[i] j k[i] k i j++ j++ j {
                                yono[sc.nextInt() - 1]++;
                        } {
                                yono[sc.nextInt() - 1]++;
                        } yono[sc.nextInt() - 1]++ yono[sc.nextInt() - 1] yono sc.nextInt() - 1 sc.nextInt() sc.nextInt sc 1 for(int ii = 0 ; ii < m ; ii++){
                                like[ii] *= yono[ii];
                        } int ii = 0 ; int ii = 0 ; ii 0 ii < m ii m ii++ ii++ ii {
                                like[ii] *= yono[ii];
                        } {
                                like[ii] *= yono[ii];
                        } like[ii] *= yono[ii] like[ii] like ii yono[ii] yono ii for(int i = 0 ; i < m ; i++){
                        if(i != 0){
                                like[0] += like[i];
                        }
                } int i = 0 ; int i = 0 ; i 0 i < m i m i++ i++ i {
                        if(i != 0){
                                like[0] += like[i];
                        }
                } {
                        if(i != 0){
                                like[0] += like[i];
                        }
                } if(i != 0){
                                like[0] += like[i];
                        } i != 0 i 0 {
                                like[0] += like[i];
                        } like[0] += like[i] like[0] like 0 like[i] like i System.out.println(like[0]) System.out.println System.out System System.out like[0] like 0 String[] args args public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                int m = sc.nextInt();
                int[] k = new int[n];
                int[] like = new int[m];
                Arrays.fill(like , 1);
                int[] yono = new int[m];
                for(int i = 0 ; i < n ; i++){
                        k[i] = sc.nextInt();
                        Arrays.fill(yono , 0);
                        for(int j = 0 ; j < k[i] ; j++){
                                yono[sc.nextInt() - 1]++;
                        }
                        for(int ii = 0 ; ii < m ; ii++){
                                like[ii] *= yono[ii];
                        }
                }
                for(int i = 0 ; i < m ; i++){
                        if(i != 0){
                                like[0] += like[i];
                        }
                }
                System.out.println(like[0]);
        }
}//0=48 public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                int m = sc.nextInt();
                int[] k = new int[n];
                int[] like = new int[m];
                Arrays.fill(like , 1);
                int[] yono = new int[m];
                for(int i = 0 ; i < n ; i++){
                        k[i] = sc.nextInt();
                        Arrays.fill(yono , 0);
                        for(int j = 0 ; j < k[i] ; j++){
                                yono[sc.nextInt() - 1]++;
                        }
                        for(int ii = 0 ; ii < m ; ii++){
                                like[ii] *= yono[ii];
                        }
                }
                for(int i = 0 ; i < m ; i++){
                        if(i != 0){
                                like[0] += like[i];
                        }
                }
                System.out.println(like[0]);
        }
}//0=48 Main
import java.util.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                int m = sc.nextInt();
                int[] k = new int[n];
                int[] like = new int[m];
                Arrays.fill(like , 1);
                int[] yono = new int[m];
                for(int i = 0 ; i < n ; i++){
                        k[i] = sc.nextInt();
                        Arrays.fill(yono , 0);
                        for(int j = 0 ; j < k[i] ; j++){
                                yono[sc.nextInt() - 1]++;
                        }
                        for(int ii = 0 ; ii < m ; ii++){
                                like[ii] *= yono[ii];
                        }
                }
                for(int i = 0 ; i < m ; i++){
                        if(i != 0){
                                like[0] += like[i];
                        }
                }
                System.out.println(like[0]);
        }
}//0=48
//鶏になれ