#include <bits/stdc++.h>
using namespace std;
int n, m;
int on[10], p[10];
vector<int> s[10];
int ans = 0;
void dfs(int i) {
  if (i == n) {
    bool ok = true;
    for (int j = 0; j < (m); ++j) {
      int cnt = 0;
      for (auto k : s[j])
        if (on[k]) cnt++;
      if (cnt % 2 != p[i]) ok = false;
    }
    if (ok) ans++;
    return;
  }
  on[i] = 0;
  dfs(i + 1);
  on[i] = 1;
  dfs(i + 1);
}
int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);
  cin >> n >> m;
  for (int i = 0; i < (m); ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < (k); ++j) {
      int t;
      cin >> t;
      --t;
      s[i].push_back(t);
    }
  }
  for (int i = 0; i < (m); ++i) cin >> p[i];
  dfs(0);
  cout << ans << endl;
}
