#include <bits/stdc++.h>
using namespace std;
vector<int> aux;
long long ans = 0;
void func(vector<vector<int>> v, vector<bool> is_even, int idx) {
  if (idx == -1) {
    ans++;
    return;
  }
  int l = v[idx].size();
  for (int i = 0; i <= (1 << l) - 1; i++) {
    vector<int> local;
    for (int j = l - 1; j >= 0; j--) {
      int temp = (i & (1 << j)) >> j;
      local.push_back(temp);
    }
    int cnt = 0;
    for (auto it : local)
      if (it == 1) cnt++;
    if ((is_even[idx] && cnt % 2 == 0) || (!is_even[idx] && cnt % 2 == 1)) {
      for (int j = 0; j < (int)local.size(); j++)
        if (aux[v[idx][j]] != -1) continue;
      for (int j = 0; j < (int)local.size(); j++) aux[v[idx][j]] = 1;
      func(v, is_even, idx - 1);
      for (int j = 0; j < (int)local.size(); j++) aux[v[idx][j]] = -1;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n, m, k;
  cin >> n >> m;
  vector<vector<int>> v;
  aux.resize(n, -1);
  for (int i = 0; i < m; i++) {
    cin >> k;
    vector<int> local(k, 0);
    for (int j = 0; j < k; j++) {
      cin >> local[j];
      local[j]--;
    }
    v.push_back(local);
  }
  vector<bool> is_even(m, true);
  for (int i = 0; i < m; i++) {
    cin >> k;
    if (k) is_even[i] = false;
  }
  func(v, is_even, m - 1);
  cout << ans << "\n";
  return 0;
}
