#include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
int n, m, ans, k[11], p[11], s[11][11], l[11];
vector<int> v[11];
inline string Itoa(int x) {
  string s = "";
  while (x >= 2) {
    s = char(x % 2 + 48) + s;
    x /= 2;
  }
  s = char(x + 48) + s;
  return s;
}
inline bool check(string x) {
  memset(l, 0, sizeof(l));
  int nn = 1;
  for (register int i = x.length() - 1; i >= 0; i--, nn++)
    if (x[i] == '1')
      for (register int j = 0; j < v[nn].size(); j++) l[v[nn][j]]++;
  for (register int i = 1; i <= m; i++)
    if (l[i] % 2 != p[i]) return false;
  return true;
}
int main() {
  scanf("%d%d", &n, &m);
  for (register int i = 1; i <= m; i++) {
    scanf("%d", &k[i]);
    for (register int j = 1; j <= k[i]; j++) {
      scanf("%d", &s[i][j]);
      v[s[i][j]].push_back(i);
    }
  }
  for (register int i = 1; i <= m; i++) scanf("%d", &p[i]);
  for (register int i = 0; i <= (1 << n); i++)
    if (check(Itoa(i))) ans++;
  printf("%d", ans);
}
