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