#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> connect(m);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int i = 0; i < k; i++) {
      int s;
      cin >> s;
      s--;
      connect[i].push_back(s);
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; i++) cin >> p[i];
  int ans = 0;
  for (int i = 0; i < 1 << n; i++) {
    bool isok = true;
    for (int j = 0; j < m; j++) {
      int c = 0;
      for (int id : connect[j]) {
        if (i >> id & 1) c++;
      }
      c %= 2;
      if (c != p[j]) isok = false;
    }
    if (isok) ans++;
  }
  cout << ans << endl;
}
