"use strict";
const main = input => {
    input = input.trim().split('\n');
    const nm = input.shift().split(' ').map(x => Number(x));
    const n = nm[0], m = nm[1];
    const p = input.pop().split(' ').map(x => Number(x));
    input = input.map(x => x.split(' ').slice(1).map(y => Number(y)));
    // console.log(n,p,input);
    const checkOn = (sw, state) => {
        sw = Math.pow(2, sw-1);
        return (sw & state) === sw
    };
    let count = 0;
    for(let i=0; i<Math.pow(2, n); i++) {
        let light = 0;
        for(let j=0; j<m; j++) {
            let swCount = 0;
            input[j].forEach(sw => {
                if (checkOn(sw,i)) swCount++;
            });
            if (swCount%2 === p[j]) light++;
        }
        if (light === m) count++;
    }
    console.log(count);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));