input = require('fs').readFileSync('/dev/stdin', 'utf8')
lines = input.split('\n')
line = lines.shift().split(' ')
N = line[0] * 1
M = line[1] * 1
k = []
for(i=0; i<M ; i++) {
    k[i] = lines[i].split(' ').slice(1).map((x) => x * 1)
    arr = new Array(N).fill(0)
    for (j=0;j<k[i].length;j++) {
        arr[N - k[i][j]] = 1
    }
    k[i] = parseInt(arr.join(''),2)
}
p = lines[i].split(' ').map((x) => x * 1)
max = Math.pow(2, N)
cnt = 0
for (i=0; i<max; i++) {
    bool = true
    for(j=0; j<M ; j++) {
        t = (i & k[j]).toString(2)
        c = 0
        for (s = 0; s < t.length; s++) {
            if (t[s] == 1) {
                c++
            }
        }
        bool = bool && (c % 2 == p[j])
    }
    if (bool) cnt++
}

console.log(cnt)

