#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> k(M);
  vector<vector<int>> s(M, vector<int>(N));
  vector<int> p(M);
  for (int i = 0; i < M; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (long long int i = 0; i <= pow(2, N); i++) {
    bitset<10> b(i);
    string B = b.to_string();
    int chk = 0;
    for (int j = 0; j < M; j++) {
      int sum = 0;
      for (int l = 0; l < k[j]; l++) {
        if (B[s[j][l] + 9 - N] == '1') {
          sum++;
        }
      }
      if (sum % 2 != p[j]) {
        break;
      }
      chk++;
    }
    if (chk == M) {
      ans++;
    }
  }
  cout << ans << endl;
}
