#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s[m];
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int s_;
      cin >> s_;
      s_--;
      s[i].push_back(s_);
    }
  }
  int p[m];
  for (int i = 0; i < m; i++) cin >> p[i];
  int ans = 0;
  for (int i = 0; i < (1 << n); i++) {
    int swich[m];
    for (int j = 0; j < n; j++) {
      swich[j] = (i >> j) & 1;
    }
    int light = m;
    int num;
    for (int j = 0; j < m; j++) {
      num = 0;
      for (int l = 0; l < s[j].size(); l++) {
        if (swich[s[j][l]] == 1) {
          num++;
        }
      }
      if (num % 2 != p[j]) {
        light--;
        break;
      }
    }
    if (light == m) {
      ans++;
    }
  }
  cout << ans << endl;
}
