#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> s(M, vector<int>(10));
  for (int i = 0, k; i < M; i++) {
    cin >> k;
    for (int j = 0; j < k; j++) cin >> s[i][j];
  }
  vector<int> p(M);
  for (auto& i : p) cin >> i;
  int ans = 0;
  for (int i = 0; i < (1 << N); i++) {
    int cnt1 = 0;
    for (int j = 0; j < M; j++) {
      int cnt2 = 0;
      for (int k = 0; k < s[j].size(); k++)
        if (i & (1 << (s[j][k] - 1))) cnt2++;
      if (cnt2 % 2 == p[j]) cnt1++;
    }
    if (cnt1 == N) ans++;
  }
  cout << ans << endl;
}
