#include <bits/stdc++.h>
using namespace std;
int n, m;
int ans;
int cnt[15];
int k[15];
int s[15][15];
int p[15];
inline void dfs(int now) {
  if (now == m + 1) {
    bool flag = true;
    for (int i = 1; i <= m; i++) {
      int tot = 0;
      for (int j = 1; j <= k[i]; j++) {
        if (cnt[s[i][j]]) {
          tot++;
        }
      }
      if (tot % 2 != p[i]) {
        flag = false;
        break;
      }
    }
    if (flag) ans++;
    return;
  }
  for (int i = 1; i <= n; i++) {
    cnt[i]++;
    dfs(now + 1);
    cnt[i]--;
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d", &k[i]);
    for (int j = 1; j <= k[i]; j++) {
      scanf("%d", &s[i][j]);
    }
  }
  for (int i = 1; i <= m; i++) scanf("%d", &p[i]);
  dfs(1);
  printf("%d", ans);
  return 0;
}
