#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> len(m), p(m);
  vector<vector<int>> s(m, vector<int>(n, -1));
  for (int i = 0; i < m; i++) {
    cin >> len[i];
    for (int j = 0; j < len[i]; j++) {
      cin >> s[i][j];
      s[i][j]--;
    }
  }
  for (int i = 0; i < m; i++) cin >> p[i];
  int ans = 0;
  for (int i = 0; i < (1 << n); i++) {
    set<int> on_bit;
    for (int j = 0; j < n; j++)
      if (i & (1 << j)) on_bit.insert(j);
    int cnt = 0;
    for (int j = 0; j < m; j++) {
      bool bulb = p[j];
      for (int k = 0; k < len[j]; k++) {
        if (on_bit.count(s[j][k])) bulb ^= 1;
      }
      if (bulb == 1) cnt++;
    }
    if (cnt == m) ans++;
  }
  cout << ans << '\n';
  return 0;
}
