var lines = [];
var s = []; var p = [];
var N, M, ans = 0;

var readline = require('readline')
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});


rl.on('line', (x) => {
    lines.push(x)
});

rl.on('close', () => {
    N = Number(lines[0].split(" ")[0])
    M = Number(lines[0].split(" ")[1])

    for (var i = 0; i < M; i++) { s.push(lines[i + 1].split(" ").filter((v, i) => i > 0).map(i => Number(i))); }
    p = lines[M + 1].split(" ");

    dfs(0, []);
    console.log(ans)
});

function dfs(n, comb) {
    if (n === N) { calc(comb); return (0) }
    else {
        for (var i = 0; i < 2; i++) {
            comb[n] = i
            dfs(n + 1, comb)
        }
    }
}

function calc(comb) {
    var on = 0;
    for (var i = 0; i < s.length; i++) {
        var cnt = 0;

        for (var j = 0; j < s[i].length; j++) { if (comb[s[i][j] - 1] === 1) { cnt++; } }
        if (cnt % 2 === Number(p[i])) { on++ }
    }

    if (on === M) { ans++ }
    return (0)
}
