#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int k[n], s[10][10], p[m];
  for (int i = 0; i < m; ++i) {
    cin >> k[i];
    for (int j = 0; j < k[i]; ++j) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < m; ++i) {
    cin >> p[i];
  }
  int cnt = 0, fl = 0, flag = 0;
  for (int bit = 0; bit < (1 << n); ++bit) {
    fl = 0;
    flag = 0;
    for (int j = 0; j < m; ++j) {
      for (int l = 0; l < k[j]; ++l) {
        if (bit & (1 << (s[j][l] - 1))) {
          fl++;
        }
      }
      if (fl % 2 != p[j]) {
        flag = 1;
      }
    }
    if (flag == 0) {
      cnt++;
    }
  }
  cout << cnt;
  return 0;
}
