import itertools
N,M = list(map(int,input().split()))
k_lis = []
for i in range(M):
    k_lis.append(list(map(int,input().split())))
P = list(map(int,input().split()))
switch_list = list(itertools.product('01',repeat = N))
ans = 0
sub = 0

for sl in range(len(switch_list)):#スイッチ全探索
    if  '1' in  (switch_list[sl]):#スイッチが少なくとも一つ点灯
        flag = 0
        for i in range(M):#電球１つ１つを探索していく
            counter = 0
            for j in range(1,k_lis[i][0]+1):
                if switch_list[sl][k_lis[i][j]-1] == '1' :
                    counter += 1
                    
            if counter %2 != P[i]:
                flag = 1
                break
        if flag == 0:    
            ans += 1
print(ans)
