#include <bits/stdc++.h>
using namespace std;
bool sw[11];
vector<int> con[11];
int ps[11];
int dfs(int cur, int n) {
  if (cur == n) {
    int lsum = 0;
    for (int i = 0; i < n; i++) {
      int sum = 0;
      for (int j = 0; j < con[i].size(); j++) {
        sum += sw[con[i][j] - 1] ? 1 : 0;
      }
      lsum += sum % 2 == ps[i] ? 1 : 0;
    }
    return lsum == n ? 1 : 0;
  } else {
    int res = 0;
    sw[cur] = true;
    res += dfs(cur + 1, n);
    sw[cur] = false;
    res += dfs(cur + 1, n);
    return res;
  }
}
int main(void) {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      con[i].push_back(s);
    }
  }
  for (int i = 0; i < m; i++) {
    int p;
    cin >> p;
    ps[i] = p;
  }
  cout << dfs(0, n) << endl;
  return 0;
}
