const main = (input) => {
  var inputs = input.trim().split("\n");
  var N = inputs[0].split(" ")[0]-0;
  var M = inputs[0].split(" ")[1]-0;
  var dlist = [];
  for(var i=0;i<M;i++){
    dlist.push(inputs[i+1].split(" ").filter((v,i)=>i>0).map(v=>v-0));
  }
  var slist = inputs[inputs.length-1].split(" ").map(v=>v-0);

  var ans = 0;
  start:for(var i=0;i<Math.pow(2,N);i++){
    var sw = ("0000000000" + i.toString(2)).slice(-N);
    for(var j=0;j<dlist.length;j++){
      var sum = 0;
      for(var k=0;k<dlist[j].length;k++){
        if(sw[dlist[j][k]-1]=="1") sum+=1;
      }
      if(slist[j] != sum%2) continue start;
    }
    ans++;
  }

  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));
