#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, j, k, kazu, kari, amari, max = 1, gomi, hantei, kotae, ans = 0;
  cin >> n >> m;
  int a[m][n], p[m];
  for (i = 0; i < n; i++) {
    max *= 2;
  }
  for (i = 0; i < m; i++) {
    for (j = 0; j < n; j++) {
      a[i][j] = 0;
    }
  }
  for (i = 0; i < m; i++) {
    cin >> gomi;
    for (j = 0; j < gomi; j++) {
      cin >> k;
      a[i][k] = 1;
    }
  }
  for (i = 0; i < m; i++) {
    cin >> p[i];
  }
  for (kazu = 0; kazu < max; kazu++) {
    kotae = 1;
    for (i = 0; i < m; i++) {
      hantei = 0;
      kari = kazu;
      for (j = n - 1; j >= 0; j--) {
        amari = kari % 2;
        kari /= 2;
        if (a[i][j] == 1 && amari == 1) {
          hantei++;
        }
      }
      if (hantei % 2 != p[i]) {
        kotae *= 0;
      }
    }
    ans += kotae;
  }
  cout << ans;
}
