#include <bits/stdc++.h>
using ll = long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> s(m, vector<int>(10));
  vector<int> p(m), k(m);
  for (int i = 0; i < m; ++i) {
    cin >> k[i];
    for (int j = 0; j < k[i]; ++j) {
      cin >> s[i][j];
    }
  }
  int ans2 = 0;
  for (int i = 0; i < m; ++i) cin >> p[i];
  for (int bit = 0; bit < (1 << n); ++bit) {
    int ans = 0;
    for (int j = 0; j < m; ++j) {
      int count = 0;
      for (int i = 0; i < k[j]; ++i) {
        if (bit & (1 << s[j][i] + 1)) {
          ++count;
        }
      }
      if (count % 2 == p[j]) ++ans;
    }
    if (ans == m) ++ans2;
  }
  cout << ans2 << endl;
  return 0;
}
