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