#include <bits/stdc++.h>
int main(void) {
  int n, m;
  scanf("%d%d", &n, &m);
  int k[m][n + 1];
  int p[m];
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n + 1; j++) {
      k[i][j] = 0;
    }
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", &k[i][0]);
    for (int j = 1; j < n + 1; j++) {
      scanf("%d", &k[i][j]);
    }
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", &p[i]);
  }
  int flag;
  int ar[n];
  int cnt[m];
  int ans = 0;
  for (int i = 0; i < pow(2, n); i++) {
    for (int j = 0; j < n; j++) {
      if ((1 & i >> j) == 1) {
        ar[j] = 1;
      } else {
        ar[j] = 0;
      }
    }
    for (int q = 0; q < m; q++) {
      cnt[q] = 0;
    }
    for (int r = 0; r < n; r++) {
      if (ar[r] == 0) {
        continue;
      } else {
        for (int l = 0; l < m; l++) {
          for (int o = 1; o < n + 1; o++) {
            if (r + 1 == k[l][o]) {
              cnt[l]++;
              break;
            }
          }
        }
      }
    }
    flag = 1;
    for (int r = 0; r < m; r++) {
      if (cnt[r] % 2 != p[r]) {
        flag = 0;
        break;
      }
    }
    if (flag == 1) {
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}
