#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  map<int, bool> mp[m];
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      s--;
      mp[i][s] = true;
    }
  }
  int p[m];
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  queue<int> ess, tmp;
  bool flag = true;
  int ans = 0;
  for (int bit = 0; bit < (1ll << n); bit++) {
    for (int i = 0; i < n; i++) {
      if (bit & (1 << i)) ess.push(i);
    }
    tmp = ess;
    flag = true;
    if (!tmp.empty()) {
      for (int i = 0; i < m; i++) {
        int cnt = 0;
        tmp = ess;
        while (!tmp.empty()) {
          int on = tmp.front();
          tmp.pop();
          if (mp[i][on]) cnt++;
        }
        if (cnt % 2 != p[i]) flag = false;
      }
      if (flag) ans++;
      while (!ess.empty()) ess.pop();
    }
  }
  cout << ans << endl;
}
