#include <bits/stdc++.h>
const int MAX_N = 10;
int main() {
  int N, M, connection[MAX_N] = {};
  std::cin >> N >> M;
  for (int i = 0; i < M; ++i) {
    int k;
    std::cin >> k;
    for (int j = 0; j < k; ++j) {
      int s;
      std::cin >> s;
      --s;
      connection[s] |= (1 << i);
    }
  }
  int ans = 0;
  for (int b = 0; b < (1 << N); ++b) {
    int state = 0;
    for (int i = 0; i < N; ++i) {
      if ((b >> i) & 1) {
        state ^= connection[i];
      }
    }
    if (state == (1 << M) - 1) ++ans;
  }
  std::cout << ans << std::endl;
}
