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