#include <bits/stdc++.h>
using namespace std;
signed main(void) {
  int n, m, cnt, ans;
  cin >> n >> m;
  vector<int> s[m];
  int p[m];
  bool ok;
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int st;
      cin >> st;
      s[i].push_back(st);
    }
  }
  for (int i = 0; i < m; i++) cin >> p[i];
  ans = 0;
  for (int bit = 1; bit < (1 << n); bit++) {
    vector<int> v;
    for (int i = 0; i < n; i++) {
      if (bit & (1 << i)) {
        v.push_back(i + 1);
      }
    }
    ok = true;
    for (int j = 0; j < m; j++) {
      cnt = 0;
      for (int k = 0; k < s[j].size(); k++) {
        for (int i = 0; i < v.size(); i++) {
          if (v[i] == s[j][k]) cnt++;
        }
      }
      if (cnt % 2 != p[j]) ok = false;
    }
    if (ok) ans++;
  }
  cout << ans << endl;
  return 0;
}
