package main

import "fmt"

// Solve the problem of ABC128 C
func main() {
	var n, m int
	fmt.Scan(&n, &m)
	klist := make([]int, m)
	slist := make([][]int, m)
	for i := 0; i < m; i++ {
		fmt.Scan(&klist[i])
		slist[i] = make([]int, klist[i])
		for j := 0; j < klist[i]; j++ {
			fmt.Scan(&slist[i][j])
		}
	}
	plist := make([]int, m)
	for l := 0; l < m; l++ {
		fmt.Scan(&plist[l])
	}

	count := 0
	for bits := 0; bits < (1 << uint64(n)); bits++ {
		state := make([]int, n)
		for i := 0; i < n; i++ {
			state[i] = bits >> uint64(i) & 1
		}
		ok := true
		for j := 0; j < m; j++ {
			sum := 0
			for _, sNo := range slist[j] {
				sum += state[sNo-1]
			}
			if sum%2 != plist[j] {
				ok = false
				break
			}
		}
		if ok {
			count++
		}
	}
	fmt.Println("count: ", count)
}