#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, c, K, res = 0;
  cin >> n >> m;
  vector<vector<int>> s(m);
  for (int i = 0; i < m; ++i) {
    cin >> K;
    for (int j = 0; j < K; ++j) {
      cin >> c;
      s[i].push_back(c - 1);
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; ++i) cin >> p[i];
  vector<bool> sw(n);
  vector<int> num;
  bool found = false;
  for (int i = 0; i < (1 << n); ++i) {
    int i0 = i;
    found = true;
    for (int j = 0; j < m; ++j, (i0 >>= 1)) sw[j] = i0 % 2;
    num = vector<int>(m, 0);
    for (int j = 0; j < m; ++j)
      for (auto k : s[j]) num[j] += (int)sw[k];
    for (int j = 0; j < m; ++j) {
      if (num[j] % 2 != p[j]) {
        found = false;
        break;
      }
    }
    if (found) res++;
  }
  cout << res;
  return 0;
}
