#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> P(M);
  vector<int> k(M);
  vector<vector<int> > s(M, vector<int>(M, 0));
  for (int i = 0, i_len = (M); i < i_len; ++i) {
    cin >> k[i];
    for (int j = 0, j_len = (k[i]); j < j_len; ++j) {
      cin >> s[i][j];
      s[i][j] = pow(2, s[i][j] - 1);
    }
  }
  for (int i = 0, i_len = (M); i < i_len; ++i) cin >> P[i];
  int cnt = 0;
  for (int i = 1, i_end = pow(2, N) + 1; i < i_end; ++i) {
    bool flag = true;
    for (int j = 0, j_len = (M); j < j_len; ++j) {
      int suml = 0;
      for (int l = 0, l_len = (k[j]); l < l_len; ++l) {
        if (s[j][l] & i) suml++;
      }
      if ((suml % 2) != P[j]) flag = false;
    }
    if (flag) cnt++;
  }
  cout << cnt << endl;
  return 0;
}
