#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int k[m], p[m];
  int s[m];
  int ans = 0;
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    s[i] = 0;
    for (int j = 0; j < k[i]; j++) {
      int in;
      cin >> in;
      s[i] = s[i] | (1 << (in - 1));
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  for (int i = 0; i < (1 << n); i++) {
    int cc = 0;
    for (int j = 0; j < m; j++) {
      int x;
      int c = 0;
      x = s[j] & i;
      for (int k = 0; k < m; k++) {
        c += ((x >> k) & 1);
      }
      if ((c & 1) == p[j]) {
        cc++;
      }
    }
    if (cc == m) {
      ans++;
    }
  }
  cout << ans << endl;
}
