N,M = map(int, input().split())
ks_list = [list(map(int,input().split())) for i in range(M)]
p_list = list(map(int, input().split()))

all_list = []
for i in range(2**N):
    all_list.append([])
    num_str = bin(i)[2:]
    if len(num_str) < N:
        for j in range(N - len(num_str)):
            all_list[i].append(0)
    for k in range(len(num_str)):
        all_list[i].append(int(bin(i)[2:][k]))


ans_num = 0
a = 0
for ans in all_list:#答えのこうほ
    flag = True

    for i, ks in enumerate(ks_list):# 条件
        middle_ans = 0
        for j in range(0,len(ks)):
            
            middle_ans += ans[ks[j]-1]
        
        if middle_ans % 2 == p_list[i]:
            a += 1
        else:
            flag = False
        
    if flag == True:
        ans_num += 1
print(ans_num)