#include <bits/stdc++.h>
using namespace std;
set<int> se;
int dfs(int i, int n, int m, int *k, int **s, int *p) {
  if (i == n) {
    bool can = true;
    for (int j = 0; j < m; j++) {
      int count = 0;
      for (int l = 0; l < k[j]; l++) {
        if (se.find(s[j][l]) != se.end()) count++;
      }
      if (count % 2 != p[j]) can = false;
    }
    if (can)
      return 1;
    else
      return 0;
  }
  int ans = 0;
  se.insert(i);
  ans += dfs(i + 1, n, m, k, s, p);
  se.erase(i);
  ans += dfs(i + 1, n, m, k, s, p);
  return ans;
}
int main() {
  int n, m;
  cin >> n >> m;
  int *k = new int[m];
  int **s = new int *[m];
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    s[i] = new int[k[i]];
    for (int j = 0; j < k[i]; j++) cin >> s[i][j];
  }
  int *p = new int[m];
  for (int i = 0; i < m; i++) cin >> p[i];
  cout << dfs(0, n, m, k, s, p) << endl;
  return 0;
}
