#include <bits/stdc++.h>
using namespace std;
const long long MOD = 2;
void solve(int &res, const vector<int> &k, const vector<vector<int>> &s,
           const vector<int> &p, vector<int> &state, int pos) {
  if (pos == state.size()) {
    bool isOK = true;
    for (int i = 0; i < s.size(); i++) {
      int v = 0;
      for (int j = 0; j < k[i]; j++) {
        v += state[s[i][j]];
      }
      if (v % 2 != p[i]) {
        isOK = false;
        break;
      }
    }
    if (isOK) {
      res++;
    }
    return;
  }
  state[pos] = 0;
  solve(res, k, s, p, state, pos + 1);
  state[pos] = 1;
  solve(res, k, s, p, state, pos + 1);
}
int main() {
  int n = 0, m = 0;
  cin >> n >> m;
  vector<int> k(m, 0);
  vector<vector<int>> s(m, vector<int>(n, 0));
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> s[i][j];
    }
  }
  vector<int> p(m, 0);
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  vector<int> state(n, 0);
  int res = 0;
  solve(res, k, s, p, state, 0);
  cout << res << endl;
  return 0;
}
