function Main(input) {
    input = input.trim().split("\n");
    tmp = input[0].split(" ");
    var N = parseInt(tmp[0],10);
    var M = parseInt(tmp[1],10);
    var p = input[input.length-1].split(" ");
    for(var i = 0; i < p.length; i++){
        p[i] = parseInt(p[i],10);
    }
    var count = 0;

    var sum;
    for(var i = 0; i < p.length; i++){
        sum += p[i];
    }
    if(sum == 0){
        count++;
    }
    for(var i = 1; i < Math.pow(2,N); i++){
        var toBinary = n => n.toString(2);
        var str = toBinary(i);
        while(str.length < 10){
            str = "0" + str;
        }
        var s = [];
        for(var j = 1; j <= 10; j++){
            if(str.charAt(10-j) == 1){
                s.push(j);
            }
        }
        var isOK = true;
        for(var j = 1; j <= M; j++){
            var sm = input[j].split(" ");
            var c = 0;
            for(var m = 1; m < sm.length; m++){
                for(var n = 0; n < s.length; n++){
                    if(sm[m].indexOf(s[n]) != -1){
                        c++;
                        break;
                    }
                }
            }
            if(c%2 != p[j-1]){
                isOK = false;
            }
        }
        if(isOK){
            count++;
        }
    }
    console.log(count);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));