#include <bits/stdc++.h>
using ll = long long;
using namespace std;
constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;
int main(void) {
  int n, m;
  cin >> n >> m;
  vector<vector<int> > s(m);
  for (int i = 0; i < m; ++i) {
    int k;
    cin >> k;
    s[i].resize(k);
    for (int j = 0; j < k; ++j) {
      cin >> s[i][j];
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; ++i) {
    cin >> p[i];
  }
  int ans = 0;
  for (int bit = 1; bit < (1 << n); ++bit) {
    bool f = true;
    for (int j = 0; j < m; ++j) {
      int x = 0;
      for (int k = 0; k <= s[j].size(); ++k) {
        int a = s[j][k];
        if (bit & (1 << a)) x ^= 1;
      }
      if (x != p[j]) f = false;
    }
    ans += f;
  }
  cout << ans << endl;
  return 0;
}
