import java.util.*;
public class xiaowuc1_2 {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    List<List<String>> problems = new ArrayList<>();
    int n = sc.nextInt();
    int k = sc.nextInt();
    for(int i = 0; i < n; i++) {
      int t = sc.nextInt();
      List<String> topics = new ArrayList<>();
      for(int j = 0; j < t; j++) {
        topics.add(sc.next());
      }
      problems.add(topics);
    }
    int ret = 0;
    for(int mask = 0; mask < (1 << n); mask++) {
      if(Integer.bitCount(mask) != k) continue;
      Map<String, Integer> freq = new HashMap<>();
      for(int i = 0; i < n; i++) {
        if((mask&(1<<i)) == 0) continue;
        for(String topic: problems.get(i)) {
          freq.put(topic, freq.getOrDefault(topic, 0) + 1);
        }
      }
      boolean good = true;
      for(String topic: freq.keySet()) {
        if(freq.get(topic) * 2 + 1 > k) {
          good = false;
        }
      }
      if(good) ret++;
    }
    System.out.println(ret);
  }
}