n, m = list(map(int,input().split()))

k = []

s = []



for i in range(m):

    temp = list(map(int, input().split()))

    temp_k = temp[0]

    temp_s = temp[1:]

    k.append(temp_k)

    s.append(temp_s)



p = list(map(int, input().split()))



ans = 0

for i in range(2**n):

    on = bin(i)[2:].rjust(n,"0")

    cond = 0

    for j in range(m):

        cnt = sum(list(map(int,[on[k] for k in range(n) if k+1 in s[j]])))

        

        if cnt % 2 == p[j]:

            cond += 1



    if cond == m:

        ans += 1



print(ans)


N, M = list(map(int, input().split()))

K = []

S = []

for _ in range(M):

	tmp = list(map(int ,input().split()))

	K.append(tmp[0])

	tmp.pop(0)

	S.append(tmp)



P = list(map(int, input().split()))





ans = 0

for i in range(2**N):

	flg = [0 for _ in range(M)]

	for j in range(N):

		if i & (1 << j):

			for k in range(M):

				if j+1 in S[k]:

					flg[k] += 1



	cond = 1

	for l in range(M):

		if P[l] != (flg[l] % 2):

			cond = 0

			break



	if cond:

		ans += 1



print(ans)
n, m = list(map(int, input().split()))
k = []
s = []
for i in range(m):
    temp = list(map(int, input().split()))
    temp_k = temp[0]
    temp_s = temp[1:]
    k.append(temp_k)
    s.append(temp_s)
p = list(map(int, input().split()))
ans = 0
for i in range(2**n):
    on = bin(i)[2:].rjust(n, "0")
    cond = 0
    for j in range(m):
        cnt = sum(list(map(int, [on[k] for k in range(n) if k + 1 in s[j]])))
        if cnt % 2 == p[j]:
            cond += 1
    if cond == m:
        ans += 1
print(ans)

N, M = list(map(int, input().split()))
K = []
S = []
for _ in range(M):
    tmp = list(map(int, input().split()))
    K.append(tmp[0])
    tmp.pop(0)
    S.append(tmp)
P = list(map(int, input().split()))
ans = 0
for i in range(2**N):
    flg = [0 for _ in range(M)]
    for j in range(N):
        if i & (1 << j):
            for k in range(M):
                if j + 1 in S[k]:
                    flg[k] += 1
    cond = 1
    for l in range(M):
        if P[l] != (flg[l] % 2):
            cond = 0
            break
    if cond:
        ans += 1
print(ans)

-n, m = list(map(int, input().split())) -k = [] -s = [] -for i in range(m): -    temp = list(map(int, input().split())) -    temp_k = temp[0] -    temp_s = temp[1:] -    k.append(temp_k) -    s.append(temp_s) -p = list(map(int, input().split())) +N, M = list(map(int, input().split())) +K = [] +S = [] +for _ in range(M): +    tmp = list(map(int, input().split())) +    K.append(tmp[0]) +    tmp.pop(0) +    S.append(tmp) +P = list(map(int, input().split())) -for i in range(2**n): -    on = bin(i)[2:].rjust(n, "0") -    cond = 0 -    for j in range(m): -        cnt = sum(list(map(int, [on[k] for k in range(n) if k + 1 in s[j]]))) -        if cnt % 2 == p[j]: -            cond += 1 -    if cond == m: +for i in range(2**N): +    flg = [0 for _ in range(M)] +    for j in range(N): +        if i & (1 << j): +            for k in range(M): +                if j + 1 in S[k]: +                    flg[k] += 1 +    cond = 1 +    for l in range(M): +        if P[l] != (flg[l] % 2): +            cond = 0 +            break +    if cond: