use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: usize, m: usize,
    }
    let mut l = vec![];
    for _ in 0..m {
        input! {
            k: usize,
            s: [Usize1; k],
        }
        let mut x = 0u64;
        for j in s {
            x |= 1 << j;
        }
        l.push(x)
    }
    input! {
        p: [u32; m]
    }

    let mut res = 0;
    'A: for i in 0..1 << n {
        for j in 0..m {
            if (l[j] & i).count_ones() % 2 != p[j] {
                continue 'A;
            }
        }
        res += 1;
    }
    println!("{}", res);
}
