#include <bits/stdc++.h>
using namespace std;
int g[15][15];
bool flag[1050000];
const int INF = 1001001001;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  int ans = 0;
  int p = 0;
  for (int i = 0; i < m; ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      int s;
      cin >> s;
      s--;
      a[s] |= 1 << i;
    }
    int x;
    cin >> x;
    p |= x << i;
    for (int s = 0; s < (1 << n); s++) {
      int t = 0;
      for (int i = 0; i < n; ++i) {
        if (s >> i & 1) {
          t ^= a[i];
        }
      }
      if (t == p) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
