function Main(input) {
  const data = input.split("\n");
  const [n, m] = data[0].split(" ").map(n => Number(n));
  const ps = data[m+1].split(" ").map(n => Number(n));
  let result = 0;
    for (let i = 0; i < 2 ** n; i++) {
        let str = i.toString(2);
        for (let tmp = 0; tmp < m - str.length; tmp++) {
            str = "0" + str;
        }
    const switches = str.split("").map(s => Number(s));
    let isOk = true;
    for (let j = 1; j <= m; j++) {
    	const sList = data[j].split(" ");
      	let onNum = 0;
      	for (let k = 1; k <= sList[0]; k++) {
          if (switches[sList[k] - 1] === 1) onNum++;
        }
      	if (onNum%2 !== ps[j-1]) {
          isOk = false;
          break;
        }
      }
    if (isOk) result++;
  }
  console.log(result);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));