package main

import (
	"fmt"
)

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

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

	ans := 0
L:
	for i := 0; i < (1 << uint(n)); i++ {
		for j := 0; j < m; j++ {
			c := 0
			for _, v := range s[j] {
				if (i>>uint(v))&1 == 1 {
					c++
				}
			}
			c %= 2
			if c != p[j] {
				continue L
			}
		}
		ans++
	}
	fmt.Println(ans)
}
