package main

import (
	"fmt"
)

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

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

	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++ {
			count := 0
			for _,k := range s[j] {
				if ((1 << (k-1)) & i) == (1 << (k-1)) {
					count++
				}
			}

			if count%2 != p[j] {
				f = false
			}
		}
		if f {
			ans++
		}
	}
	fmt.Println(ans)
}
