#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> k(100), p(100);
vector<vector<int>> s(100, vector<int>(100));
int sum = 0;
void dfs(int now, vector<int> sw) {
  bool ok = true;
  if (now == n + 1) {
    for (int i = 0; i < m; i++) {
      int count = 0;
      for (int j = 0; j < k[i]; j++) {
        if (sw[s[i][j]] == 1) {
          count++;
        }
      }
      if (p[i] != (count % 2)) {
        ok = false;
        break;
      }
    }
    if (ok) {
      sum++;
    }
  }
  if (now > n) {
    return;
  }
  dfs(now + 1, sw);
  sw[now] = 1;
  dfs(now + 1, sw);
}
int main() {
  cin >> n >> m;
  vector<int> swt(n + 1, 0);
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> s[j][i];
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  swt[1] = 1;
  dfs(1, swt);
  cout << sum << endl;
  return 0;
}
