#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> adj[15];
int nyala[15];
bool cek(int x) {
  for (int i = 1; i <= m; i++) {
    int tmp = 0;
    for (int j = 0; j < adj[i].size(); j++) {
      int cur = adj[i][j];
      if ((1 << cur) & x) tmp++;
    }
    if (nyala[i] != tmp % 2) return 0;
  }
  return 1;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int x;
    scanf("%d", &x);
    for (int j = 1; j <= x; j++) {
      int y;
      scanf("%d", &y);
      adj[i].push_back(y);
    }
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d", &nyala[i]);
  }
  int ans = 0;
  for (int i = 0; i < (1 << n); i++) {
    if (cek(i)) ans++;
  }
  printf("%d\n", ans);
  return 0;
}
