#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
const long long INF = 1LL << 60;
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> lights(M);
  for (long long i = 0; i < M; i++) {
    int k;
    cin >> k;
    for (long long j = 0; j < k; j++) {
      int s;
      cin >> s;
      lights[i].push_back(s - 1);
    }
  }
  vector<int> p(M);
  for (long long i = 0; i < M; i++) cin >> p[i];
  long long ans = 0;
  for (int i = 0; i < (1 << N); i++) {
    bitset<10> s(i);
    bool flag = true;
    for (long long i = 0; i < M; i++) {
      int tmp = 0;
      for (long long j = 0; j < lights[i].size(); j++) tmp += s.test(j);
      if (tmp % 2 != p[i]) {
        flag = false;
        break;
      }
    }
    if (flag == true) ans++;
  }
  cout << ans << endl;
}
