use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

static mut ans: usize = 0;

fn rec(
    n: usize,
    m: usize,
    status: &mut Vec<usize>,
    //mut ans: u32,
    switch: &Vec<Vec<usize>>,
    p: &Vec<u32>,
    //) -> u32 {
) {
    //最深まで探索し、状態を判定する
    if status.len() == n {
        //println!("ans{} status{:?}",ans,status);
        let mut on = 0;
        let mut light = vec![false; m];
        for j in 0..m {
            for k in switch[j].iter() {
                if (status[*k - 1]) == 1 {
                    on += 1;
                }
            }
            //点灯の確認
            if on % 2 == p[j] {
                light[j] = true;
            }
        }
        //全点灯の確認
        if light.iter().all(|c| *c == true) {
            unsafe {
                ans += 1;
            }
        }
    } else {
        //再帰全探索
        for c in 0..2 {
            status.push(c);
            //ans = rec(n, m, status, ans, switch, p);
            rec(n, m, status, switch, p);
            status.pop();
        }
    }

    //return ans;
}
fn main() {
    let n: usize = read();
    let m: usize = read();
    let mut switch: Vec<Vec<usize>> = vec![vec![0; 0]; m]; //m個の空のvecを用意

    for i in 0..m {
        let k: usize = read();
        for _ in 0..k {
            let s: usize = read();
            switch[i].push(s);
        }
    }
    let p: Vec<u32> = (0..m).map(|_| read()).collect();

    let mut status = Vec::new();
    //let ans = rec(n, m, &mut status, 0, &switch, &p);
    rec(n, m, &mut status, &switch, &p);
    unsafe {
        print!("{}", ans);
    }
}
