package main

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

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	N := readInt()
	M := readInt()
	s := make([][]int, M)
	for i := range s {
		k := readInt()
		s[i] = make([]int, k)
		for j := range s[i] {
			s[i][j] = readInt() - 1
		}
	}
	p := make([]int, M)
	for i := range p {
		p[i] = readInt()
	}

	var ans int
	DoWithExhaustive01(N, func(b []int) {
		for i := range s {
			var sum int
			for j := range s[i] {
				k := s[i][j]
				sum += b[k]
			}
			if sum%2 != p[i] {
				return
			}
		}
		ans++
	})
	println(ans)

}

// -----------------------------------------------------------------------------

// DoWithExhaustiveBits(n, fn) calls fn with []bool for each n-bit true/false pattern
// e.g.
// DoWithExhaustiveBits(10, func(b []bool) { fmt.Println(b) }
// -> [false, false, false, false, false, false, false, false, false, false]
//    [true, false, false, false, false, false, false, false, false, false]
//    [false, true, false, false, false, false, false, false, false, false]
//    [true, true, false, false, false, false, false, false, false, false]
//    [false, false, true, false, false, false, false, false, false, false]
//    ...
func DoWithExhaustiveBits(n int, fn func([]bool)) {
	N := 1 << uint(n)
	a := make([]bool, n)
	for i := 0; i < N; i++ {
		for j := 0; j < n; j++ {
			k := n - j - 1
			if i&(1<<uint(j)) == 0 {
				a[k] = false
			} else {
				a[k] = true
			}
		}
		fn(a)
	}
}

// DoWithExhaustive01(n, fn) calls fn with []int for each n-bit 0/1 pattern
// e.g.
// DoWithExhaustive01(10, func(b []int) { fmt.Println(b) }
// -> [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
//    [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
//    [0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
//    [1, 1, 0, 0, 0, 0, 0, 0, 0, 0]
//    [0, 0, 1, 0, 0, 0, 0, 0, 0, 0]
//    ...
func DoWithExhaustive01(n int, fn func([]int)) {
	N := 1 << uint(n)
	a := make([]int, n)
	for i := 0; i < N; i++ {
		for j := 0; j < n; j++ {
			k := n - j - 1
			if i&(1<<uint(j)) == 0 {
				a[k] = 0
			} else {
				a[k] = 1
			}
		}
		fn(a)
	}
}


Measured memory_bytes: 640