package main

import (
	"fmt"
)

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

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

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

	ans := 0

	for i := 0; i < (1<<n); i++ {
		f := true
		for j := 0; j < m; j++ {
			on := 0
			for _, e := range d[j] {
				if i & (1<<(e-1)) == (1<<(e-1)) {
					on++
				}
			}

			if on%2 != p[j] {
				f = false
				break
			}
		}

		if f {
			ans++
		}
	}

	fmt.Println(ans)
}
