import numpy as np

N, M = map(int, input().split())
lamplist = []
for i in range(M):
    A = list(map(int, input().split()))
    lamplist.append(A)
oddeven_ans = list(map(int, input().split()))

switch = np.zeros(N)
ans = 0

for j in range(2 ** N):
    flag = 0
    oddeven = 0
    for k in range(N):
        switch[k] = j % 2
        j //= 2
    for p in range(M):
        for r in range(1, lamplist[p][0]+1):

            if switch[lamplist[p][r] - 1] == 1:
                oddeven += 1
        if (int(oddeven % 2)) != int(oddeven_ans[p]):
            flag = 1
    if flag == 0:
        ans += 1

print("{}".format(ans))
