#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int> > s(M);
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; k++) {
      int number_switch = 0;
      number_switch--;
      cin >> number_switch;
      s[i].push_back(number_switch);
    }
  }
  vector<int> p(M);
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    bool on = true;
    for (int i = 0; i < M; i++) {
      int number_on = 0;
      for (auto v : s[i]) {
        if (bit & (1 << v)) number_on++;
      }
      if (number_on % 2 != p[i]) {
        on = false;
      }
    }
    if (on) ans++;
  }
  cout << ans;
}
