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

fn main() {
    input! {
        n: usize,
        m: usize,
        s: [[Usize1]; m],
        p: [usize; m],
    }

    let mut count = 0;
    'calc: for bit in 0..(1 << n) {
        for i in 0..m {
            let mut s_count = 0;
            for &s_j in &s[i] {
                if bit & (1 << s_j) > 0 {
                    s_count += 1;
                }
            }
            if s_count % 2 != p[i] {
                continue 'calc;
            }
        }
        count += 1;
    }
    println!("{}", count);
}
