#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> k(m), p(m);
  vector<vector<int> > s(m, vector<int>(10));
  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 b = 0; b < (1 << n); ++b) {
    vector<int> on(n, 0);
    for (int i = 0; i < (n); ++i) {
      if ((b >> i) & 1) {
        on[i]++;
      }
    }
    bool all = true;
    for (int i = 0; i < (m); ++i) {
      all &= (p[i] == on[i] % 2);
    }
    if (all) ans++;
  }
  cout << ans << endl;
  ;
  return 0;
}
