#include <bits/stdc++.h>
using namespace std;
int main() {
  int two[11] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024};
  int n, m, ans = 0;
  bool flag = true;
  cin >> n >> m;
  int s[m][m], p[m], k[m];
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> s[i][j];
      s[i][j]--;
    }
  }
  for (int i = 0; i < m; i++) cin >> p[i];
  int b = 1;
  for (int i = 0; i < n; i++) b *= 2;
  for (int i = 0; i < b; i++) {
    flag = true;
    for (int j = 0; j < m; j++) {
      int counter = 0;
      for (int h = 0; h < k[j]; h++) {
        if ((two[s[j][h]] & i) > 0) counter++;
      }
      if (counter % 2 != p[j]) {
        flag = false;
      }
    }
    if (flag) ans++;
  }
  cout << ans << endl;
  return 0;
}
