import math, string
# 10進数整数を2進数文字列に変換する関数
# decimal : 10進数整数
# press   : 上位桁の0を切り詰めるフラグ
def toBinary(decimal, press=True):
    if decimal == 0: return '0'
    bin_str = ""
    i = 31
    while i >= 0:
        bi = int((decimal & int(math.pow(2, i))) >> i)
        bin_str += str(bi)
        i -= 1
    if press:
        try:
            bin_str = bin_str[bin_str.index('1'):]
        except ValueError:
            print('error')
            bin_str = '0'
    return bin_str

    
    
N,M= map(int,input().split())
light_list=[]
even_or_odd=[]
for i in range(M):
    temp=list(map(int,input().split()))
    temp = temp[1:]
    light_list.append(temp)

even_or_odd=list(map(int,input().split()))
pattern_list=[]
ans =0
for i in range(2**N):
    bin_temp = toBinary(i).rjust(N,'0')
    bin_temp=bin_temp[::-1]
    pattern_list.append(bin_temp)
    
    for index,light in enumerate(light_list):
        light_count=0
        for switch_num in light:
            light_count += int(bin_temp[switch_num-1])
    if light_count%2 != even_or_odd[index]:
        continue
    ans += 1
            


print(ans//2)