"use strict";
function I(t,i){this._s=t.split("\n"),this._c=0,this._l=0,this._f=i||Number}I.prototype.a=function(t){var i=this._s[this._l];if(i){var s=i.trim().split(" "),h=s[this._c];return this._c++,s.length===this._c&&(this._c=0,this._l++),t?t(h):this._f(h)}},I.prototype.l=function(t){var i=this._s[this._l];if(i)return this._c=0,this._l++,i.split(" ").map(t||this._f)},module.exports=I;

function main(input) {
  var o = new I(input);

  var n = o.a();
  var m = o.a();

  var arr = [];
  for (var i = 0; i < m; i++) {
    arr[i] = [];
    var k = o.a();
    for (var j = 0; j < k; j++) {
      arr[i].push(o.a());
    }
  }
  var p =  o.l();

  var count = 0;
  for (var i = 0; i < Math.pow(2, n); i++) {
    var str = i.toString(2);
    while(str.length < n) str = "0"+str;
    // console.log({str});
    var flag = true;
    for (var j = 0; j < m; j++) {
      var lightCount = 0;
      arr[j].forEach(x => {
        if (str[x - 1] === "1") {
          lightCount += 1;
        }
      });

      // console.log({lightCount, pj: p[j]});
      if (lightCount % 2 !== p[j]) {
        flag = false;
        break;
      }
    }
    if (flag) {
      count += 1;
    }
  }

  console.log(count);
}


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