#include <bits/stdc++.h>
using namespace std;
int N, M;
int k[10], s[10][10], p[10];
int ans = 0;
void calc(vector<int>& v) {
  bool flag = true;
  int ON = 0;
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < k[i]; j++) {
      if (v[s[i][j] - 1] == 1) ON++;
    }
    if (ON % 2 != p[i]) flag = false;
  }
  if (flag == true) ans++;
}
void dfs(int d, vector<int>& v) {
  if (d == N) {
    calc(v);
  } else {
    for (int i = 0; i < 2; i++) {
      v.push_back(i);
      dfs(d + 1, v);
      v.pop_back();
    }
  }
}
int main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) cin >> s[i][j];
  }
  for (int i = 0; i < M; i++) cin >> p[i];
  vector<int> v;
  dfs(0, v);
  cout << ans << endl;
}
