#include <bits/stdc++.h>
using namespace std;
int a[20][20], pp[20];
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n, m, ans = 0;
  cin >> n >> m;
  for (int i = (1); i <= (m); i++) {
    cin >> a[i][0];
    for (int o = (1); o <= (a[i][0]); o++) cin >> a[i][o];
  }
  for (int i = (1); i <= (m); i++) cin >> pp[i];
  for (int i = (1); i <= ((1 << n) - 1); i++) {
    int cmp = i, cur[20], cnt = 0;
    for (int o = (1); o <= (10); o++) cur[o] = 0;
    while (cmp) cur[++cnt] = cmp & 1, cmp >>= 1;
    int light[20];
    for (int o = (1); o <= (10); o++) light[o] = 0;
    for (int o = (1); o <= (m); o++)
      for (int p = (1); p <= (a[o][0]); p++) light[o] += cur[a[o][p]];
    int gg = 0;
    for (int o = (1); o <= (m); o++)
      if ((light[o] % 2) != pp[o]) {
        gg++;
        break;
      }
    if (!gg) ans++;
  }
  cout << ans << "\n";
}
