#include <bits/stdc++.h>
using namespace std;
int a[20][20];
int b[20];
int m, n;
int c[20];
int vis[20];
int p[20];
int ans = 0;
void dfs(int pos, int c[]) {
  if (pos == n + 1) {
    int f = 0;
    for (int i = 0; i < m; i++) {
      int s = 0;
      for (int j = 0; j < b[i]; j++) {
        if (c[a[i][j]] == 1) s++;
      }
      if (s == 0 || s % 2 != p[i]) f = 1;
    }
    if (!f) ans++;
    return;
  }
  c[pos] = 1;
  dfs(pos + 1, c);
  c[pos] = 0;
  dfs(pos + 1, c);
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> b[i];
    for (int j = 0; j < b[i]; j++) cin >> a[i][j], vis[a[i][j]]++;
  }
  for (int i = 0; i < m; i++) cin >> p[i];
  dfs(1, c);
  int couts = 0;
  for (int i = 1; i < n; i++) {
    if (vis[i] == 0) couts++;
  }
  if (couts == 0)
    cout << ans << endl;
  else
    cout << ans * couts * 2 << endl;
  return 0;
}
