#include <bits/stdc++.h>
using namespace std;
vector<int> light[15];
int p[15];
int vis[15];
int ans;
int temp[15];
int n, m;
void dfs(int x) {
  if (x == n + 1) {
    memset(temp, 0, sizeof(temp));
    for (int i = 1; i <= n; i++) {
      if (vis[i] != 0) {
        for (int j = 0; j < light[i].size(); j++) {
          int b = light[i][j];
          temp[b]++;
        }
      }
    }
    for (int i = 1; i <= m; i++)
      if (temp[i] % 2 != p[i]) return;
    ans++;
    return;
  }
  dfs(x + 1);
  vis[x] = 1;
  dfs(x + 1);
  vis[x] = 0;
}
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);
      light[i].push_back(y);
    }
  }
  for (int i = 1; i <= m; i++) scanf("%d", &p[i]);
  dfs(1);
  printf("%d\n", ans);
}
