#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<bool>> sw(m, vector<bool>(m, false));
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      sw[i][s - 1] = true;
    }
  }
  int ans = 0;
  for (int bit = 1; bit < (1 << n); bit++) {
    bool flag = true;
    for (int i = 0; i < m; i++) {
      int p, cnt = 0;
      cin >> p;
      for (int j = 0; j < n; j++) {
        if (bit >> j & 1 && sw[i][j]) cnt++;
      }
      if (cnt % 2 != p) {
        flag = false;
      }
    }
    if (flag) {
      ans++;
    }
  }
  cout << ans << endl;
}
