#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, s;
  cin >> a >> b;
  s = 0;
  int c[15], d[15][15], t, p[15];
  for (int i = 0; i < b; i++) {
    for (int j = 0; j < a; j++) d[i][j] == 0;
  }
  for (int i = 0; i < b; i++) {
    cin >> c[i];
    for (int j = 0; j < c[i]; j++) {
      cin >> t;
      d[i][t - 1] = 1;
    }
  }
  for (int i = 0; i < b; i++) cin >> p[i];
  for (int bit = 0; bit < (1 << a); bit++) {
    int sum = 0;
    for (int j = 0; j < b; j++) {
      int ans = 0;
      for (int i = 0; i < a; ++i) {
        if (bit & (1 << i)) {
          if (d[j][i] == 1) ans++;
        }
      }
      if (ans % 2 == p[j]) sum++;
    }
    if (sum == b) s++;
  }
  cout << s << endl;
}
