#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m, ans;
  cin >> n >> m;
  vector<vector<int>> ks(m);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      cin >> ks[i][j];
      ks[i][j]--;
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; i++) cin >> p[i];
  for (int i = 0; i < (1 << n); i++) {
    bool ok = true;
    for (int j = 0; j < m; j++) {
      int count = 0;
      for (int num : ks[j]) {
        if ((i >> num) & 1) count++;
      }
      count %= 2;
      if (count != p[j]) ok = false;
    }
    if (ok) ans++;
  }
  cout << ans << endl;
  return 0;
}
