#include <bits/stdc++.h>
using namespace std;
int n, m, k, s, p[11], ans = 0;
vector<set<int>> bulb;
vector<bool> states;
void switches(vector<bool> sts, int ptr, int cnt) {
  if (ptr <= n) {
    int c = 0;
    for (int i = 0; i < sts.size(); i++) {
    }
    for (int i = 0; i < m; i++) {
      c = 0;
      for (auto it = bulb[i].begin(); it != bulb[i].end(); ++it) {
        if (sts[*it]) c++;
      }
      if (p[i] % 2 == 0) {
        if (c % 2 == 0) cnt++;
      } else {
        if (c % 2 != 0) cnt++;
      }
    }
    if (cnt == m) ans++;
    sts[ptr] = !sts[ptr];
    switches(sts, ptr + 1, 0);
    sts[ptr] = !sts[ptr];
    switches(sts, ptr + 1, 0);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> k;
    set<int> tem;
    for (int j = 0; j < k; j++) {
      cin >> s;
      tem.insert(s - 1);
    }
    bulb.push_back(tem);
  }
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  for (int i = 0; i < n; i++) {
    states.push_back(true);
  }
  switches(states, 0, 0);
  cout << ans / 2;
  return 0;
}
