package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	s := make([][]int, m)

	for i := 0; i < m; i++ {
		k := 0
		fmt.Scan(&k)
		s[i] = make([]int, k)
		for j := 0; j < k; j++ {
			fmt.Scan(&s[i][j])
			s[i][j]--
		}
	}
	p := make([]int, m)
	for i := 0; i < m; i++ {
		fmt.Scan(&p[i])
	}

	ans := 0

	for i := 0; i < 1<<n; i++ {
		ok := true
		for j := 0; j < m; j++ {
			on := 0
			for _, num := range s[j] {
				if ((i >> num) & 1) == 1 {
					on++
				}
			}

			if on%2 != p[j] {
				ok = false
			}
		}
		if ok {
			ans++
		}
	}
	fmt.Println(ans)
}
