#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> k(m);
  vector<vector<int> > s(m);
  int ss;
  vector<int> p(m);
  int bit = 0;
  int i, j;
  for (i = 0; i < m; i++) {
    cin >> k[i];
    for (j = 0; j < k[i]; j++) {
      cin >> ss;
      s[i].push_back(ss);
    }
  }
  for (i = 0; i < m; i++) {
    cin >> p[i];
  }
  int tmp = 0;
  int light = 0;
  int ans = 0;
  for (bit = 0; bit < 1 << n; bit++) {
    light = 0;
    for (i = 0; i < m; i++) {
      tmp = 0;
      for (j = 0; j < k[i]; j++) {
        if (bit & 1 << (s[i][j] - 1)) tmp++;
      }
      if (tmp % 2 == p[i]) light++;
    }
    if (light == n) ans++;
  }
  cout << ans << endl;
}
