package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)

	n, m := oneInt(), oneInt()

	conditions := [][]int{}

	for i := 0; i < m; i++ {
		k := oneInt()
		conditions = append(conditions, scanNums(k))
	}

	ps := scanNums(m)

	ans := 0
	for i0 := 0; i0 < 2; i0++ {
		condition := make([]int, 10)
		condition[0] = i0
		if n == 1 && canLighten(condition[:n], conditions, ps) {
			ans++
		}
		for i1 := 0; i1 < 2; i1++ {
			condition[1] = i1
			//fmt.Printf("%#v\n", condition[:2])
			if n == 2 && canLighten(condition[:n], conditions, ps) {
				ans++
			}
			for i2 := 0; i2 < 2; i2++ {
				condition[2] = i2
				if n == 3 && canLighten(condition[:n], conditions, ps) {
					ans++
				}
				for i3 := 0; i3 < 2; i3++ {
					condition[3] = i3
					if n == 4 && canLighten(condition[:n], conditions, ps) {
						ans++
					}
					for i4 := 0; i4 < 2; i4++ {
						condition[4] = i4
						if n == 5 && canLighten(condition[:n], conditions, ps) {
							ans++
						}
						for i5 := 0; i5 < 2; i5++ {
							condition[5] = i5
							if n == 6 && canLighten(condition[:n], conditions, ps) {
								ans++
							}
							for i6 := 0; i6 < 2; i6++ {
								condition[6] = i6
								if n == 7 && canLighten(condition[:n], conditions, ps) {
									ans++
								}
								for i7 := 0; i7 < 2; i7++ {
									condition[7] = i7
									if n == 8 && canLighten(condition[:n], conditions, ps) {
										ans++
									}
									for i8 := 0; i8 < 2; i8++ {
										condition[8] = i8
										if n == 9 && canLighten(condition[:n], conditions, ps) {
											ans++
										}
										for i9 := 0; i9 < 2; i9++ {
											condition[9] = i9
											if n == 10 && canLighten(condition[:n], conditions, ps) {
												ans++
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}

	fmt.Println(ans)
}

func generateCondition(inputs [][]int, i int, n int) [][]int {
	if len(inputs[0]) == n {
		return inputs
	}
	for _, input := range inputs {
		input = append(input, i)
	}
	inputs0 := generateCondition(inputs, 0, n)
	inputs1 := generateCondition(inputs, 1, n)

	inputs0 = append(inputs0, inputs1...)
	return inputs0
}

func canLighten(condition []int, conditions [][]int, ps []int) bool {
	for i, con := range conditions {
		sum := 0
		for _, s := range con {
			if condition[s-1] == 1 {
				sum++
			}
		}
		//fmt.Println(sum)
		if sum%2 != ps[i] {
			return false
		}
	}
	return true
}

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

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

func scanNums(len int) (nums []int) {
	for i := 0; i < len; i++ {
		nums = append(nums, oneInt())
	}
	return nums
}

func scanStrings(len int) (strs []string) {
	for i := 0; i < len; i++ {
		strs = append(strs, oneStr())
	}
	return strs
}

func abs(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

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

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}

func cumSum(nums []int) []int {
	sums := []int{0}

	for i := 0; i < len(nums); i++ {
		sums = append(sums, sums[i]+nums[i])
	}
	return sums
}


Measured memory_bytes: 640