'use strict';
console.log(function(args){
  const tmp = args.trim().split('\n').map(a=>a.split(' ').map(v=>v|0));
  const N = tmp[0][0], M = tmp[0][1];
  const p = tmp[M+1];
  const k = Array(M),s = Array(M);
  let count = 0;
  for ( let i = 1; i <= M; i++ ) {
    k[i-1] = tmp[i][0];
    s[i-1] = tmp[i].slice(1).map(v=>v-1);
  }
  TEST: for ( let state = 0; state < 1<<N; state++ ) {
    for ( let i = 0; i < M; i++ ) {
      let bulb = !p[i];
      for ( let j = 0; j < k[i]; j++ ) {
        if ( state & (1 << s[i][j] ) ) {
          bulb^=1;
        }
      }
      if ( !bulb ) continue TEST;
    }
    count++;
  }
  return count.toString();
}(require('fs').readFileSync('/dev/stdin', 'utf8')));
