#include <bits/stdc++.h>
using namespace std;
int dfs(int, vector<int>, vector<vector<int>>, vector<int>, int);
bool check(vector<int>, vector<vector<int>>, vector<int>);
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> v(m);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int tmp;
      cin >> tmp;
      v[i].push_back(tmp);
    }
  }
  vector<int> p;
  for (int i = 0; i < m; i++) {
    int tmp;
    cin >> tmp;
    p.push_back(tmp);
  }
  vector<int> s(n);
  int ans = dfs(0, s, v, p, n);
  cout << ans << endl;
}
int dfs(int pos, vector<int> s, vector<vector<int>> v, vector<int> p, int n) {
  if (pos == n) {
    if (check(s, v, p)) {
      return 1;
    } else {
      return 0;
    }
  }
  s[pos] = 0;
  int ans1 = dfs(pos + 1, s, v, p, n);
  s[pos] = 1;
  int ans2 = dfs(pos + 1, s, v, p, n);
  return ans1 + ans2;
}
bool check(vector<int> s, vector<vector<int>> v, vector<int> p) {
  int sum = 0;
  int index = 0;
  for (vector<int> i : v) {
    for (int j : i) {
      sum += s[j - 1];
    }
    if ((sum % 2 == 0 && p[index] == 1) || (sum % 2 == 1 && p[index] == 0)) {
      return false;
    }
    index++;
  }
  return true;
}
