#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int> > s(n);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int s_in;
      cin >> s_in;
      s[s_in - 1].push_back(j);
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (int k = 0; k < (1 << n); k++) {
    vector<int> o(m, 0);
    for (int i = 0; i < n; i++) {
      if (k & (1 << i)) {
        for (auto itr = s[i].begin(); itr != s[i].end(); itr++) {
          o[*itr]++;
        }
      }
    }
    bool flg = true;
    for (int i = 0; i < m; i++) {
      if (o[i] % 2 != p[i] % 2) {
        flg = false;
        break;
      }
    }
    if (flg) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
