#include <bits/stdc++.h>
using namespace std;
int num[11];
int main() {
  int n, m;
  int ans = 0;
  vector<int> con[11];
  int p[11];
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int amount;
    scanf("%d", &amount);
    for (int j = 0; j < amount; j++) {
      int temp;
      scanf("%d", &temp);
      con[i].push_back(temp);
    }
  }
  for (int i = 1; i <= m; i++) scanf("%d", &p[i]);
  for (int i = 0; i < 1 << n; i++) {
    memset(num, 0, sizeof(num));
    int temp = i;
    for (int j = 1; j <= n; j++) {
      int now = temp & 1;
      if (now) {
        for (int k = 0; k < con[j].size(); k++) num[con[j][k]]++;
      }
      temp = temp >> 1;
    }
    int flag = 0;
    for (int j = 1; j <= m; j++) {
      if (num[j] % 2 != p[j] % 2) flag = 1;
    }
    if (flag == 0) ans++;
  }
  printf("%d", ans);
  return 0;
}
