#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    n: usize,
    m: usize,
    }
    let mut ss = vec![];
    for _ in 0..m {
        input! {
        k: usize,
        s: [Usize1; k]
        }
        ss.push(s);
    }
    input! {
    p: [usize; m]
    }
    let mut map = vec![vec![]; n];
    for i in 0..m {
        for &j in &ss[i] {
            map[j].push(i);
        }
    }
    let mut ans = 0;
    for i in 0..1 << n {
        let mut c = vec![0; m];
        for j in 0..n {
            if 1 << j & i > 0 {
                for &k in &map[j] {
                    c[k] = (c[k] + 1) % 2;
                }
            }
        }
        if c == p {
            ans += 1;
        }
    }
    println!("{}", ans);
}
