#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> k(m);
  vector<vector<int>> s(m, vector<int>(m));
  vector<int> p(m);
  for (int i = 0; i < (m); ++i) {
    cin >> k[i];
    for (int j = 0; j < (k[i]); ++j) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < (m); ++i) cin >> p[i];
  int res = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    bool flag = 0;
    for (int i = 0; i < (m); ++i) {
      bool parity = 0;
      for (int j = 0; j < (k[i]); ++j) {
        if ((1 << (s[i][j] - 1)) & bit) parity ^= 1;
      }
      if (parity == p[i])
        continue;
      else {
        flag = 1;
        break;
      }
    }
    if (flag == 0) res++;
  }
  cout << res << endl;
  return 0;
}
