"use strict";
function Main(input) {
  const args = input.split('\n');
  const NM = args.shift().split(' ').map(m => parseInt(m));
  const N = NM.shift();
  const M = NM.shift();
  const s = [];
  let idx = 0;
  while (args.length > 2) {
    const ks = args.shift().split(' ').map(m => parseInt(m));
    ks.shift();
    ks.map(m => m - 1).forEach(f => {
      s[f] = !!s[f] ? s[f] : [];
      s[f].push(idx);
    });
    idx++;
  }
  const p = args.shift().split(' ').map(m => parseInt(m));
  let count = calc(true, s, p, emptyArray(M), N - 1);
  count += calc(false, s, p, emptyArray(M), N - 1);
  console.log(count);
}

function calc(bool, s, p, Ms, i) {
  if (bool && !!s[i]) {
    s[i].forEach(bulb => Ms[bulb]+= 1);
  }
  if (i > 0) {
    let count = calc(true, s, p, [].concat(Ms), i - 1);
    count += calc(false, s, p, [].concat(Ms), i - 1);
    return count;
  }
  return Ms.filter((f, i) => f % 2 === p[i]).length === Ms.length ? 1 : 0;
}

function emptyArray(M) {
  const arr = [];
  for(let i = 0; i < M; i++) {
    arr[i] = 0;
  }
  return arr;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
