#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> k(m), p(m);
  vector<vector<int>> s(m, vector<int>(n));
  for (int i = 0; i < (m); ++i) {
    cin >> k[i];
    for (int j = 0; j < (k[i]); ++j) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < (m); ++i) cin >> p[i];
  int cnt2 = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    bitset<10> sw(bit);
    bool ok = true;
    for (int i = 0; i < (m); ++i) {
      int cnt = 0;
      for (int j = 0; j < (k[i]); ++j) {
        if (sw[s[i][j]] == 1) cnt++;
      }
      if (cnt % 2 != p[i]) ok = false;
    }
    if (ok) cnt2++;
  }
  cout << cnt2 << endl;
}
