#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<int> k(M);
  vector<vector<int>> s(M, vector<int>(k));
  vector<int> p(M);
  for (int i = 0; i < (int)(M); i++) {
    cin >> k[i];
    for (int j = 0; j < (int)(k[i]); j++) {
      cin >> s[i][j];
      s[i][j]--;
    }
  }
  for (int i = 0; i < (int)(M); i++) cin >> p[i];
  int ans = 0;
  for (int bit = 0; bit < (int)((1 << N)); bit++) {
    vector<int> v;
    vector<bool> on(M, false);
    for (int i = 0; i < (int)(N); i++)
      if (bit & (1 << i)) v.push_back(i);
    int cnt2 = 0;
    for (int i = 0; i < (int)(M); i++) {
      int cnt = 0;
      for (int j = 0; j < (int)(k[i]); j++)
        if (find(v.begin(), v.end(), s[i][j]) != v.end()) cnt++;
      if (cnt % 2 == p[i]) cnt2++;
    }
    if (cnt2 == M) ans++;
  }
  cout << ans << endl;
  return 0;
}
