#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> v(m);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    v[i].resize(k);
    for (int j = 0; j < k; j++) {
      cin >> v[i][j];
      v[i][j]--;
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; i++) cin >> p[i];
  int ans = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    int flag = 1;
    for (int i = 0; i < m; i++) {
      int cnt = 0;
      for (int j = 0; j < v[i].size(); j++) {
        if (bit & (1 << j)) {
          cnt = 1 - cnt;
        }
      }
      if (cnt != p[i]) flag = 0;
    }
    if (flag) ans++;
  }
  cout << ans << endl;
}
