#include <bits/stdc++.h>
using namespace std;
int N, M;
vector<int> a[10];
int p[10];
int main() {
  cin >> N >> M;
  for (int i = 0; i < (int)(M); ++i) {
    int temp;
    cin >> temp;
    a[i].resize(temp);
    for (int j = 0; j < (int)(a[i].size()); ++j) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < (int)(M); ++i) {
    cin >> p[i];
  }
  bool f = true;
  int ans = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    f = true;
    for (int j = 0; j < M; j++) {
      int count = 0;
      for (int i = 0; i < a[j].size(); i++) {
        int temp = a[j][i] - 1;
        if (bit & (1 << temp) != 0) {
          count++;
        }
      }
      if (count % 2 != p[j]) f = false;
    }
    if (f) ans++;
  }
  cout << ans << endl;
  return 0;
}
