#include <bits/stdc++.h>
using namespace std;
const int mmax = 1e2 + 5;
bool bo[mmax][mmax];
int po[mmax];
int main() {
  memset(bo, 0, sizeof(bo));
  int n, m, k, a;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> k;
    while (k--) {
      cin >> a;
      bo[i][a] = 1;
    }
  }
  for (int i = 1; i <= m; i++) cin >> po[i];
  int ans = 0;
  for (int i = 0; i < (1 << n); i++) {
    int open = 0;
    for (int k = 1; k <= m; k++) {
      int sum = 0, tmp = 1;
      for (int j = 1; tmp <= m; j = j << 1, tmp++) {
        if (j & i && bo[k][tmp]) sum++;
      }
      if (((sum % 2) == po[k])) open++;
    }
    if (open == m) ans++;
  }
  cout << ans << endl;
}
