#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int ans = 0;
  vector<vector<int>> Connect(0);
  for (int i = 0; i < M; i++) {
    vector<int> vec(0, 0);
    int K;
    cin >> K;
    for (int j = 0; j < K; j++) {
      int s;
      cin >> s;
      vec.push_back(s);
    }
    Connect.push_back(vec);
  }
  vector<int> P(0);
  for (int i = 0; i < M; i++) {
    int p;
    cin >> p;
    P.push_back(p);
  }
  for (int bit = 0; bit < (1 << N); bit++) {
    for (int i = 0; i < M; i++) {
      int count = 0;
      for (int j = 0; j < Connect[i].size(); j++) {
        if (bit & (1 << Connect[i][j])) count++;
      }
      if (count % 2 != P[i]) break;
      if (i == M - 1) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
