#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> result(m);
  vector<vector<int>> hoge(m, vector<int>(n));
  int tmp;
  for (int i = 0; i < m; i++) {
    cin >> tmp;
    for (int v = 0; v < tmp; v++) {
      cin >> hoge[i][v];
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> result[i];
  }
  int count = 0;
  int kumi = 0;
  bool f = true;
  for (int bit = 0; bit < (1 << n); bit++) {
    f = true;
    for (int i = 0; i < m; i++) {
      for (int v = 0; v < hoge[i].size(); v++) {
        if (hoge[i][v] == 0) {
          continue;
        }
        if ((bit >> (hoge[i][v] - 1)) & 1) {
          count += 1;
        }
      }
      if (count % 2 != result[i]) {
        f = false;
      }
    }
    if (f) {
      kumi += 1;
    }
  }
  cout << kumi << endl;
}
