#include <bits/stdc++.h>
using namespace std;
int sum_digits(int num);
template <class T>
vector<T> copy_vector(vector<T> vec);
int gcd(int a, int b);
int n, m;
vector<vector<int>> s;
vector<int> p;
int solve(vector<int> state) {
  bool rtn = true;
  for (int i = 0; i < s.size(); i++) {
    vector<int> switches = s[i];
    int cnt = 0;
    for (int j = 0; j < switches.size(); j++) {
      if (state[switches[j - 1]]) {
        cnt++;
      }
    }
    if (cnt % 2 != p[i]) {
      rtn = false;
    }
  }
  return (rtn) ? 1 : 0;
}
int bfs(int idx, vector<int> switch_state) {
  if (idx == n)
    return solve(switch_state);
  else {
    vector<int> state1, state2;
    copy(switch_state.begin(), switch_state.end(), back_inserter(state1));
    copy(switch_state.begin(), switch_state.end(), back_inserter(state2));
    state1.push_back(0);
    state2.push_back(1);
    int ans1 = bfs(idx + 1, state1);
    int ans2 = bfs(idx + 1, state2);
    return ans1 + ans2;
  }
}
int main() {
  cin >> n >> m;
  s = vector<vector<int>>(m);
  p = vector<int>(m);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    s[i] = vector<int>(k, 0);
    for (int j = 0; j < k; j++) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  vector<int> v;
  cout << bfs(0, v) << endl;
  return 0;
}
int sum_digits(int num) {
  int rtn = 0;
  while (num != 0) {
    int tmp = num % 10;
    rtn += tmp;
    num /= 10;
  }
  return rtn;
}
template <class T>
vector<T> copy_vector(vector<T> vec) {
  vector<T> rtn;
  rtn.reserve(vec.size());
  copy(vec.begin(), vec.end(), back_inserter(rtn));
  return rtn;
}
int gcd(int a, int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
