#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int ans = 0;
  vector<vector<int>> mame(10);
  int p[10];
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int a;
      cin >> a;
      mame[i].push_back(a - 1);
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  for (int i = 0; i < 1 << n; i++) {
    int onoff[10] = {0};
    for (int j = 0; j < n; j++) {
      if (i >> j & 1) onoff[j] = 1;
    }
    for (int j = 0; j < n; j++) {
      int cnt = 0;
      for (int k = 0; k < mame[j].size(); k++) {
        cnt += onoff[mame[j][k]];
      }
      if (cnt == 0 || cnt % 2 != p[j]) break;
      if (j == n - 1) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
