#include <bits/stdc++.h>
using namespace std;
const int maxn = 15;
int n, m, p[maxn], ans = 0;
set<int> a[maxn];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    int k;
    scanf("%d", &k);
    while (k--) {
      int x;
      scanf("%d", &x);
      a[x].insert(i);
    }
  }
  for (int i = 1; i <= m; ++i) scanf("%d", &p[i]);
  int lim = pow(2, n);
  int swit[maxn], time[maxn];
  int run = 0;
  for (int i = 0; i < lim; i++) {
    int tmp = i, cnt = m, flag = 1;
    for (int j = 0; j < maxn; j++) swit[j] = time[j] = 0;
    while (tmp) swit[cnt--] = tmp % 2, tmp >>= 1;
    for (int j = 1; j <= m; j++)
      if (swit[j])
        for (auto it = a[j].begin(); it != a[j].end(); it++) {
          time[*it]++;
          run++;
          if (run > 10000) {
            assert(false);
          }
        }
    for (int j = 1; j <= m; j++)
      if (time[j] % 2 != p[j]) {
        flag = 0;
        break;
      }
    if (flag) ans++;
  }
  printf("%d\n", ans);
  return 0;
}
