"use strict"
function main(arg) {
    arg = arg.trim().split("\n")
    var nm = arg.shift().split(" ").map(Number)
    var n = nm[0]
    var m = nm[1]
    var p = arg.pop().split(" ").map(Number)
    // var k = []
    var s = []
    for (var i = 0; i < arg.length; i++) {
        var tmp = arg[i].split(" ").map(e => Number(e) - 1)
        tmp.shift()
        s.push(tmp)
    }
    var maps = getOnOffMap(n)
    var switchies_history = []
    var result = 0
    for (var i = 0; i < maps.length; i++) {
        var rule = maps[i]
        var switchies_history_row = []
        for (var j = 0; j < s.length; j++) {
            var count = 0
            for (var k = 0; k < s[j].length; k++) {
                var sw = s[j][k]
                if (rule[sw]) {
                    count++
                }
            }
            // 点灯するか?
            if (count % 2 === p[j]) {
                switchies_history_row.push(true)
            } else {
                switchies_history_row.push(false)
            }
        }
        // switchies_history.push(switchies_history_row)
        // console.log(switchies_history_row)
        var tmp_result_flg = true
        for (var j = 0; j < switchies_history_row.length; j++) {
            if (!switchies_history_row[j]) {
                tmp_result_flg = false
            }
        }
        if (tmp_result_flg) {
            result++
        }
    }
    console.log(result)
    // console.log(JSON.stringify(maps,null,"\t"))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

//0:on, 1:off
function getOnOffMap(s) {
    var maxLength = (Math.pow(2, s) - 1).toString(2).length
    var result = []
    for (var i = 0; i < Math.pow(2, s); i++) {
        var row = i.toString(2)
        var prefix = ''
        for (var j = row.length; j < maxLength; j++) {
            prefix += '0'
        }
        result.push((prefix + row).split("").map(e => {
            if (e === '0') return true
            if (e === '1') return false
        }))
    }
    return result
}