#include <bits/stdc++.h>
using namespace std;
int k[11];
int p[11];
int s[11][11];
int N[11];
void num2switch(int i) {
  int j = 1;
  while (i) {
    if (i % 2 == 1) {
      N[j] = 1;
    } else {
      N[j] = 0;
    }
    j++;
    i /= 2;
  }
}
int main() {
  int n, M, cnt = 0;
  cin >> n >> 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];
  }
  for (int num = 1; num < pow(2, n); num++) {
    num2switch(num);
    bool flag = false;
    for (int i = 0; i < (M); ++i) {
      if (flag) {
        break;
      }
      int tmp = 0;
      for (int j = 0; j < (k[i]); ++j) {
        tmp += N[s[i][j]];
        tmp %= 2;
      }
      if (tmp != p[i]) {
        flag = true;
      }
    }
    if (!flag) cnt++;
  }
  cout << cnt << endl;
  return 0;
}
