#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int> > s(m);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int a;
      cin >> a;
      s[i].push_back(a - 1);
    }
  }
  int p[m];
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    bool flag = true;
    for (int i = 0; i < m; i++) {
      int count = 0;
      for (int j = 0; j < s[i].size(); j++) {
        if (bit & (1 << j)) {
          count++;
        }
      }
      if (count % 2 != p[i]) {
        flag = false;
        break;
      }
    }
    if (flag) {
      ans++;
    }
  }
  cout << ans << "\n";
  return 0;
}
