#include <bits/stdc++.h>
using namespace std;
int nijou(int a) {
  int b = 1;
  for (int i = 0; i < (a - 1); i++) b *= 2;
  return b;
}
int main() {
  int n, m, ans = 0;
  cin >> n >> m;
  vector<vector<int>> a(m, vector<int>(n));
  vector<int> p(m);
  for (int i = 0; i < (m); i++) {
    cin >> a[i][0];
    for (int j = 0; j < (a[i][0]); j++) cin >> a[i][j + 1];
  }
  for (int i = 0; i < (m); i++) cin >> p[i];
  for (int i = 0; i < (1 << n); i++) {
    vector<int> s(m);
    for (int j = 0; j < (n); j++) {
      int mask = 1 << j;
      if (i & mask) {
        for (int k = 0; k < (m); k++) {
          for (int l = 0; l < (a[k][0]); l++) {
            if (nijou(a[k][l + 1]) == mask) {
              s[k]++;
            }
          }
        }
      }
    }
    bool ok = true;
    for (int j = 0; j < (m); j++) {
      if (s[j] % 2 != p[j]) ok = false;
    }
    if (ok) ans++;
  }
  cout << ans << endl;
  return 0;
}
