#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s[m];
  vector<int> p(m);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int x;
      cin >> x;
      x--;
      s[i].emplace_back(x);
    }
  }
  for (int i = 0; i < m; i++) cin >> p[i];
  int ans = 0;
  for (int bit = 0; bit <= (1 << n); bit++) {
    int ok = 0;
    for (int i = 0; i < m; i++) {
      int on = 0;
      for (int x : s[i]) {
        if ((bit >> x) & 1) on++;
      }
      if (on % 2 == p[i]) ok++;
    }
    if (ok == m) ans++;
  }
  cout << ans << endl;
}
