#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> k(m);
  vector<vector<int>> s(m, vector<int>(0));
  for (int i = 0; i << m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      int a;
      cin >> a;
      a--;
      s.at(i).push_back(a);
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  int count = 0;
  for (int i = 0; i < (1 << n); i++) {
    bool on = true;
    for (int j = 0; j < m; j++) {
      int sum = 0;
      for (int l = 0; l < k[j]; l++) {
        if (1 & (i >> s.at(j).at(l))) {
          sum++;
        }
      }
      if (sum % 2 != p[j]) break;
      if (j == m - 1) count++;
    }
  }
  cout << count << endl;
}
