#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(10, vector<int>(10, 0));
  for (int i = 0; i < (m); i++)
    for (int j = 0; j < (n); j++) g[i][j] = 0;
  vector<int> count(m, 0);
  int ans = 0;
  for (int i = 0; i < (m); i++) {
    int k;
    cin >> k;
    for (int j = 0; j < (k); j++) {
      int s;
      cin >> s;
      s--;
      g[i][s] = 1;
    }
  }
  vector<int> p(m);
  for (int i = 0; i < (m); i++) cin >> p[i];
  for (int i = 0; i < (1 << n); i++) {
    bool ok = true;
    ;
    vector<int> d(n);
    for (int j = n - 1; j >= 0; j--)
      if (i >> j & 1) d[j] = 1;
    for (int j = 0; j < (m); j++) {
      for (int k = 0; k < (n); k++) {
        if (d[k] && g[j][k]) count[j]++;
      }
      if (count[j] % 2 != p[j]) ok = false;
    }
    if (ok) ans++;
  }
  cout << ans << endl;
  return 0;
}
