package main

import "fmt"

func main() {
	var n, m uint
	fmt.Scan(&n, &m)

	lightBulbs := make([][]int, m)
	var k int
	for i := range lightBulbs {
		fmt.Scan(&k)
		lightBulbs[i] = make([]int, k)
		for j := range lightBulbs[i] {
			fmt.Scan(&lightBulbs[i][j])
		}
	}

	ps := make([]int, m)
	for i := range ps {
		fmt.Scan(&ps[i])
	}

	var (
		match int
		flag  bool
		onOff string
		ans   int
	)
	for i := 0; i < (1 << n); i++ {
		flag = true
		onOff = fmt.Sprintf("%08b", i)
		for j, l := range lightBulbs {
			match = 0
			for k := range l {
				if onOff[len(onOff)-l[k]] == '1' {
					match++
				}
			}
			if match%2 == ps[j] {
				continue
			} else {
				flag = false
				break
			}
		}
		if flag == false {
			continue
		} else {
			ans++
		}
	}

	fmt.Println(ans)
}
