def main():
	N, M = [int(n) for n in input().split(" ")]
	lights_def = [[0] * (N + 1) for i in range(M)]
	# lights_def[i] = List, i-th light (i = 0 ~ M)
	# lights_def[i][j] = 1 / 0, j-th switch is related (j = 1 ~ N)
	for i in range(M):
		tmp = [int(t) for t in input().split(" ")]
		for j in tmp[1:]:
			lights_def[i][j] = 1
	p = [int(x) for x in input().split(" ")]
	for i in range(len(p)):
		lights_def[i][0] = p[i]

	cnt = 0
	for i in range(2 ** N):
		switch_bit = list(pad_zero(format(i, 'b'), N))
		for j in range(len(lights_def)):
			light = lights_def[j]
			if sum([light[k + 1] for k in range(len(switch_bit)) if switch_bit[k] == "1"]) % 2 != light[0]:
				break
		else:
			cnt += 1

	print(cnt)

def pad_zero(s, n):
	s = str(s)
	return (("0" * n) + s)[-n:]

main() def main():
	N, M = [int(n) for n in input().split(" ")]
	lights_def = [[0] * (N + 1) for i in range(M)]
	# lights_def[i] = List, i-th light (i = 0 ~ M)
	# lights_def[i][j] = 1 / 0, j-th switch is related (j = 1 ~ N)
	for i in range(M):
		tmp = [int(t) for t in input().split(" ")]
		for j in tmp[1:]:
			lights_def[i][j] = 1
	p = [int(x) for x in input().split(" ")]
	for i in range(len(p)):
		lights_def[i][0] = p[i]

	cnt = 0
	for i in range(2 ** N):
		switch_bit = list(pad_zero(format(i, 'b'), N))
		for j in range(len(lights_def)):
			light = lights_def[j]
			if sum([light[k + 1] for k in range(len(switch_bit)) if switch_bit[k] == "1"]) % 2 != light[0]:
				break
		else:
			cnt += 1

	print(cnt) main int(n) for n in input().split(" ") for n in input().split(" ") n input().split(" ") ().split () input split " " for n in input().split(" ") int(n) int n N, M = [int(n) for n in input().split(" ")] N [int(n) for n in input().split(" ")] M [0] * (N + 1) for i in range(M) for i in range(M) i range(M) range M for i in range(M) [0] * (N + 1) [0] 0 N + 1 N 1 lights_def = [[0] * (N + 1) for i in range(M)] lights_def [[0] * (N + 1) for i in range(M)] for i in range(M):
		tmp = [int(t) for t in input().split(" ")]
		for j in tmp[1:]:
			lights_def[i][j] = 1
	 i range(M) range M int(t) for t in input().split(" ") for t in input().split(" ") t input().split(" ") ().split () input split " " for t in input().split(" ") int(t) int t tmp = [int(t) for t in input().split(" ")] tmp [int(t) for t in input().split(" ")] for j in tmp[1:]:
			lights_def[i][j] = 1
	 j tmp[1:] tmp 1: 1 lights_def[i][j] = 1 lights_def[i][j] [i] lights_def i j 1 int(x) for x in input().split(" ") for x in input().split(" ") x input().split(" ") ().split () input split " " for x in input().split(" ") int(x) int x p = [int(x) for x in input().split(" ")] p [int(x) for x in input().split(" ")] for i in range(len(p)):
		lights_def[i][0] = p[i]

	 i range(len(p)) range len(p) len p lights_def[i][0] = p[i] lights_def[i][0] [i] lights_def i 0 p[i] p i cnt = 0 cnt 0 for i in range(2 ** N):
		switch_bit = list(pad_zero(format(i, 'b'), N))
		for j in range(len(lights_def)):
			light = lights_def[j]
			if sum([light[k + 1] for k in range(len(switch_bit)) if switch_bit[k] == "1"]) % 2 != light[0]:
				break
		else:
			cnt += 1

	 i range(2 ** N) range 2 ** N 2 N switch_bit = list(pad_zero(format(i, 'b'), N)) switch_bit list(pad_zero(format(i, 'b'), N)) list pad_zero(format(i, 'b'), N) pad_zero format(i, 'b') format i 'b' N for j in range(len(lights_def)):
			light = lights_def[j]
			if sum([light[k + 1] for k in range(len(switch_bit)) if switch_bit[k] == "1"]) % 2 != light[0]:
				break
		else:
			cnt += 1

	 j range(len(lights_def)) range len(lights_def) len lights_def light = lights_def[j] light lights_def[j] lights_def j if sum([light[k + 1] for k in range(len(switch_bit)) if switch_bit[k] == "1"]) % 2 != light[0]:
				break
		 sum([light[k + 1] for k in range(len(switch_bit)) if switch_bit[k] == "1"]) % 2 != light[0] sum([light[k + 1] for k in range(len(switch_bit)) if switch_bit[k] == "1"]) % 2 sum([light[k + 1] for k in range(len(switch_bit)) if switch_bit[k] == "1"]) sum [light[k + 1] for k in range(len(switch_bit)) if switch_bit[k] == "1"] 2 light[0] light 0 break cnt += 1 cnt 1 print(cnt) print cnt def pad_zero(s, n):
	s = str(s)
	return (("0" * n) + s)[-n:] pad_zero s = str(s) s str(s) str s return (("0" * n) + s)[-n:] (("0" * n) + s)[-n:] ("0" * n) + s "0" * n "0" n s -n: -n n s s n n main() main def pad_zero(s, n):
	s = str(s)
	return (("0" * n) + s)[-n:] def pad_zero(s, n):
	s = str(s)
	return (("0" * n) + s)[-n:] pad_zero def main():
	N, M = [int(n) for n in input().split(" ")]
	lights_def = [[0] * (N + 1) for i in range(M)]
	# lights_def[i] = List, i-th light (i = 0 ~ M)
	# lights_def[i][j] = 1 / 0, j-th switch is related (j = 1 ~ N)
	for i in range(M):
		tmp = [int(t) for t in input().split(" ")]
		for j in tmp[1:]:
			lights_def[i][j] = 1
	p = [int(x) for x in input().split(" ")]
	for i in range(len(p)):
		lights_def[i][0] = p[i]

	cnt = 0
	for i in range(2 ** N):
		switch_bit = list(pad_zero(format(i, 'b'), N))
		for j in range(len(lights_def)):
			light = lights_def[j]
			if sum([light[k + 1] for k in range(len(switch_bit)) if switch_bit[k] == "1"]) % 2 != light[0]:
				break
		else:
			cnt += 1

	print(cnt) def main():
	N, M = [int(n) for n in input().split(" ")]
	lights_def = [[0] * (N + 1) for i in range(M)]
	# lights_def[i] = List, i-th light (i = 0 ~ M)
	# lights_def[i][j] = 1 / 0, j-th switch is related (j = 1 ~ N)
	for i in range(M):
		tmp = [int(t) for t in input().split(" ")]
		for j in tmp[1:]:
			lights_def[i][j] = 1
	p = [int(x) for x in input().split(" ")]
	for i in range(len(p)):
		lights_def[i][0] = p[i]

	cnt = 0
	for i in range(2 ** N):
		switch_bit = list(pad_zero(format(i, 'b'), N))
		for j in range(len(lights_def)):
			light = lights_def[j]
			if sum([light[k + 1] for k in range(len(switch_bit)) if switch_bit[k] == "1"]) % 2 != light[0]:
				break
		else:
			cnt += 1

	print(cnt) main
def main():
	N, M = [int(n) for n in input().split(" ")]
	lights_def = [[0] * (N + 1) for i in range(M)]
	# lights_def[i] = List, i-th light (i = 0 ~ M)
	# lights_def[i][j] = 1 / 0, j-th switch is related (j = 1 ~ N)
	for i in range(M):
		tmp = [int(t) for t in input().split(" ")]
		for j in tmp[1:]:
			lights_def[i][j] = 1
	p = [int(x) for x in input().split(" ")]
	for i in range(len(p)):
		lights_def[i][0] = p[i]

	cnt = 0
	for i in range(2 ** N):
		switch_bit = list(pad_zero(format(i, 'b'), N))
		for j in range(len(lights_def)):
			light = lights_def[j]
			if sum([light[k + 1] for k in range(len(switch_bit)) if switch_bit[k] == "1"]) % 2 != light[0]:
				break
		else:
			cnt += 1

	print(cnt)

def pad_zero(s, n):
	s = str(s)
	return (("0" * n) + s)[-n:]

main()