#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>(m));
  vector<int> p(m);
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) cin >> s[i][j];
  }
  for (int i = 0; i < m; i++) cin >> p[i];
  int ans = 0;
  for (int i = 0; i < (1 << n); i++) {
    bitset<10> on_off_bit(i);
    int j;
    for (j = 0; j < m; j++) {
      int buf = 0;
      for (int l = 0; l < k[j]; l++) {
        if (on_off_bit[s[j][l] - 1]) buf++;
      }
      if (buf % 2 != p[j]) break;
    }
    if (j == m) ans++;
  }
  cout << ans << endl;
}
