func readInts() -> [Int]{
    return readLine()!.split(separator: " ").map{Int($0)!};
}
let a = readInts();
let N = a[0], M = a[1];
var A: Array<Array<Int>> = Array();
for i in 0 ..< M {
    let b = readInts();
    A.append([Int]());
    for j in 0 ..< N {
        A[i].append(0);
    }
    for j in 1 ... b[0] {
        A[i][b[j]-1] = 1;
    }
}
var answer = 0;
let p = readInts();
for bit in 0 ..< (1<<N) {
    var rock = 0;
    var check: Array<Int> = Array(repeating: 0, count: 12);
    for i in 0 ..< N {
        if bit & 1<<i > 0 {
            check[i] = 1;
        }
    }
    for i in 0 ..< M {
        var count = 0;
        for j in 0 ..< N {
            if check[j] == 1 && A[i][j] == 1 {
                count += 1;
            }
        }
        if count % 2 == p[i] {
            rock += 1;
        }
    }
    if rock == M {
        answer += 1;
    }
}
print(answer);