package main

import "fmt"

func main() {
	var N, M int
	fmt.Scan(&N, &M)

	light := make(map[int]map[int]struct{})

	for i := 1; i <= M; i++ {
		var K int
		fmt.Scan(&K)
		light[i] = make(map[int]struct{})
		var tmp int
		for j := 0; j < K; j++ {
			fmt.Scan(&tmp)
			light[i][tmp] = struct{}{}
		}
	}

	p := make(map[int]int)
	for i := 1; i <= M; i++ {
		var tmp int
		fmt.Scan(&tmp)
		p[i] = tmp
	}

	ans := 0
	for i := 0; i < (1 << N); i++ {
		good := true
		for m := 1; m <= M; m++ {
			count := 0
			for j := 0; j < N; j++ {
				if i&(1<<j) > 0 {
					if _, ok := light[m][j+1]; ok {
						count++
					}
				}
			}
			if (count % 2) != p[m] {
				good = false
				break
			}
		}
		if good {
			ans++
		}
	}
	fmt.Println(ans)
}
