#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
int aa[15][15];
int la[15];
int wei[15];
void ppp(int i) {
  memset(wei, 0, sizeof(wei));
  int step = 1;
  while (i) {
    wei[step] = i % 2;
    i /= 2;
    step++;
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> aa[i][0];
    for (int j = 1; j <= aa[i][0]; j++) {
      cin >> aa[i][j];
    }
  }
  for (int i = 1; i <= m; i++) {
    cin >> la[i];
  }
  int ans = 0;
  for (int i = 0; i < pow(2, n); i++) {
    ppp(i);
    int temp = 0;
    for (int j = 1; j <= m; j++) {
      int sum = 0;
      for (int k = 1; k <= aa[j][0]; k++) {
        if (wei[k] == 1) sum++;
      }
      if (sum % 2 == la[j]) temp++;
    }
    if (temp == m) ans++;
  }
  cout << ans << endl;
}
