n,m = map(int,input().split())
s_lst = [list(map(int,input().split())) for i in range(m)]
k_lst = []
for i in range(m):
    k = s_lst.pop(s_lst[i][0])
    k_lst.append(k)
p_lst = list(map(int,input().split()))
answer = 0

for i in range(2**n): #各電球がonかoffかビット全探索
    on_lst =[0]*n
    flag = True
    for j in range(n):
        if (i>>j) & 1:
            on_lst[j] = 1
    for l in range(m): ##　一つ一つの電球について確認
        number = 0
        s = s_lst[l]
        for sw in s:
            if on_lst[sw-1]==1:
                number += 1
        if number%2 != p[i]:
            flag = False
            break
    if flag:
        answer += 1

print(answer)