#include <bits/stdc++.h>
using namespace std;
const int Maxn = 13;
int n, m, p[Maxn], ans, light[Maxn][Maxn], cnt[Maxn];
bool on[Maxn];
void cal(void) {
  for (int i = 1; i <= m; i++) {
    int tmp = 0;
    for (int j = 1; j <= cnt[i]; j++) tmp ^= on[light[i][j]];
    if (tmp != p[i]) return;
  }
  ans++;
}
void dfs(int u) {
  if (u == n + 1)
    cal();
  else {
    dfs(u + 1);
    on[u] = true;
    dfs(u + 1);
    on[u] = false;
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d", &cnt[i]);
    for (int j = 1; j <= cnt[i]; j++) scanf("%d", &light[i][j]);
  }
  dfs(1);
  printf("%d", ans);
  return 0;
}
