#2bit生成　ON=1 OFF=2
import itertools
L = [0,1]
count = 0

N,M = map(int,input().split())
k = []
s = []

for i in range(M):
    tmp = list(map(int,input().split()))
    k.append(tmp[0])
    s.append(tmp[1:])

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

bit_list = list(itertools.product([0,1],repeat = N))

for i in bit_list:
    #i番目のチェック
    # print(i)
    
    for j in range(M):
        #電球Mのチェック
        counter = 0
        tmp = list(s[j])
        # print(tmp)
        
        for l in tmp:
            # print(l)
            if i[l-1] == 1:
                counter += 1
        
        if counter % 2 != p[j-1]:
            break
        
        if j == M-1:
            count += 1

print(count)