'use strict';

function main(stdin) {
  const input = stdin.split('\n');
  const tmp = input.shift().split(' ').map(v => parseInt(v, 10));
  const N = tmp[0];
  const M = tmp[1];
  const S = input.map(v => v.split(' ').map(v => parseInt(v, 10)));
  const cond = S.pop();
  S.forEach(s => {
    s.shift();
  });
  let ans = 0;

  for (let n = 0; n < 2 ** N; ++n) {
    let flag = true;

    for (let k = 0; k < M; ++k) {
      let sum = 0;

      S[k].forEach(s => {
        sum += (n >>> (s - 1)) & 1;
      });

      if (sum % 2 !== cond[k]) {
        flag = false;
        break;
      }
    }

    if (flag) ++ans;
  }
  
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));