((stdin) => {
  const lines = stdin.trim().split('\n');
  const [n, m] = lines.shift().split(' ').map(Number);
  const lights = [];
  for (let i = 0; i < m; i++) {
    const light = lines.shift().split(' ').map(Number);
    lights.push(light.slice(1));
  }
  const mods = lines.shift().split(' ').map(Number);
  let count = 0;
  let base = '';
  for (let i = 0; i < n; i++) {
    base += '0';
  }
  for (let bit = 0; bit < Math.pow(2, n); bit++) {
    const b = (base + bit.toString(2)).slice(-n);
    let isAll = true;
    for (let i = 0; i < m; i++) {
      let onCount = 0;
      for (let j = 0; j < lights[i].length; j++) {
        onCount += Number(b[lights[i][j] - 1]);
      }
      if (onCount % 2 !== mods[i]) {
        isAll = false;
        break;
      }
    }
    if (isAll) {
      count += 1;
    }
  }
  console.log(count);
})(require('fs').readFileSync('/dev/stdin', 'utf8'));