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