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