#include <bits/stdc++.h>
using namespace std;
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}
int main() {
  int n, m;
  int ans = 0;
  cin >> n >> m;
  int k[m];
  int s[m][n];
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> s[i][j];
    }
  }
  int p[m];
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  int a = 1;
  for (int i = 1; i <= n; i++) a *= 2;
  for (int i = 0; i <= a; i++) {
    int b[n];
    int q = i;
    for (int j = 0; j < n; j++) {
      b[j] = q % 2;
      q = q / 2;
    }
    int y = 0;
    for (int j = 0; j < m; j++) {
      int x = 0;
      for (int w = 0; w < k[j]; w++) {
        x += b[s[j][w]];
      }
      if (p[j] != x % 2) y++;
    }
    if (y == 0) ans++;
  }
  cout << ans << endl;
  return 0;
}
