#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, ans;
  cin >> n >> m;
  vector<vector<int>> lmp(m);
  vector<int> p(m);
  for (int i = 0; i < (int)(m); i++) {
    int k;
    cin >> k;
    for (int j = 0; j < (int)(k); j++) {
      int ss;
      cin >> ss;
      lmp[i].push_back(ss - 1);
    }
  }
  for (int i = 0; i < (int)(m); i++) cin >> p[i];
  ans = 0;
  for (int bit = 1; bit < (1 << n); ++bit) {
    vector<int> S(n);
    for (int i = 0; i < n; ++i) {
      if (bit & (1 << i)) {
        S[i] = 1;
      }
    }
    int flg = 0;
    for (int i = 0; i < (int)(m); i++) {
      int cnt = 0;
      for (int j = 0; j < (int)(lmp[i].size()); j++) {
        if (S[lmp[i][j]] == 1) ++cnt;
      }
      if (cnt % 2 != p[i]) {
        ++flg;
        break;
        ;
      }
    }
    if (flg == 0) ++ans;
  }
  cout << ans << endl;
  return 0;
}
