package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {

	in := nextInt
	n, m := in(), in()

	lp := make([][]int, m)
	for i := 0; i < m; i++ {
		c := in()
		lp[i] = make([]int, c)
		for j := 0; j < c; j++ {
			lp[i][j] = in()
		}
	}

	p := make([]int, m)
	for i := 0; i < m; i++ {
		p[i] = in()
	}

	res := 0
	for i := 0; i < (1 << uint(n)); i++ {
		on := 0
		for j := 0; j < m; j++ {
			cnt := 0
			for k := 0; k < len(lp[j]); k++ {
				d := uint(lp[j][k] - 1)
				if ((i >> d) & 1) == 1 {
					cnt++
				}
			}
			if (cnt % 2) == p[j] {
				on++
			}
		}
		if on == m {
			res++
		}
	}

	ans := res
	fmt.Println(ans)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func anser(b bool, y string, n string) string {
	if b {
		return y
	}
	return n
}