#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> k(m), p(m);
  vector<vector<int>> s(m, vector<int>(10));
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < m; i++) cin >> p[i];
  int ans = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    bool check = true;
    for (int i = 0; i < m; i++) {
      int cnt = 0;
      for (int j = 0; j < k[i]; j++) {
        if (bit & (1 << k[j])) {
          cnt++;
        }
      }
      if (cnt % 2 != p[i]) check = false;
    }
    if (check) ans++;
  }
  cout << ans << endl;
  return 0;
}
