#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m, sw[10];
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int k;
    bitset<10> s;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int sw_tmp;
      cin >> sw_tmp;
      s.set(sw_tmp - 1);
    }
    sw[i] = s.to_ulong();
  }
  int p[20];
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (int bit = 1; bit < (1 << n); ++bit) {
    vector<int> vec;
    for (int i = 0; i < n; ++i) {
      if (bit & (1 << i)) {
        vec.push_back(i);
      }
    }
    bool flag = true;
    for (int light = 0; light < m; light++) {
      int count = 0;
      for (int i = 0; i < (int)vec.size(); ++i) {
        if (sw[light] & (1 << vec[i])) {
          count++;
        }
      }
      if (count % 2 != p[light]) {
        flag = false;
        continue;
      }
    }
    if (flag) {
      ans++;
    }
  }
  cout << ans;
  return 0;
}
