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