#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int k;
  vector<vector<int>> s(M);
  for (int i = 0; i < M; i++) {
    cin >> k;
    for (int j = 0; j < k; j++) {
      int a;
      cin >> a;
      --a;
      s[i].push_back(a);
    }
  }
  vector<int> p(M);
  for (int i = 0; i < M; i++) cin >> p[i];
  int ans = 0;
  for (int bit = 0; bit < (1 << M); ++bit) {
    int flag = 1;
    for (int i = 0; i < M; i++) {
      int count = 0;
      for (auto v : s[i]) {
        if (bit & (1 << v)) count++;
      }
      if (count % 2 != p[i]) flag = 0;
    }
    if (flag == 1) ++ans;
  }
  cout << ans << endl;
  return 0;
}
