
use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    let v: Vec<&str> = s.split_ascii_whitespace().collect();
    let (n, m) = (v[0].parse::<usize>().unwrap(), v[1].parse::<usize>().unwrap());

    let mut lamps = Vec::new();
    for _i in 0..m {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        let s = buf.split_ascii_whitespace().skip(1).map(|i| i.parse::<usize>().unwrap() - 1).collect::<Vec<usize>>();
        lamps.push(s);
    }

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let p = buf.split_ascii_whitespace().map(|i| i.parse::<usize>().unwrap()).collect::<Vec<usize>>();

    let mut ans = 0;
    'a: for bit in 0..(1 << n) {
        // スイッチのON/OFFの情報
        let mut swc = vec![false; n];
        for sft in 0..n {
            if (bit >> sft) & 1 == 1 {
                swc[sft] = true;
            }
        }

        for (i, ls) in lamps.iter().enumerate() {
            if !ls.iter().filter(|&l| swc[*l]).count() % 2 == p[i] {
                continue 'a;
            }
        }
        ans += 1;
    }

    println!("{}", ans);
}
