#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, m, mask[10], cnt = 0;
void rec(int bits, int d) {
  if (d < 0) {
    cnt += (bits + 1) == (1 << m);
    return;
  }
  rec(bits, d - 1);
  rec(bits ^ mask[d], d - 1);
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    int k, s;
    scanf("%d", &k);
    for (int j = 0; j < k; j++) {
      scanf("%d", &s);
      mask[s - 1] ^= (1 << i);
    }
  }
  rec(0, n - 1);
  printf("%d\n", cnt);
}
