n,m = map(int,input().split())
ls = []
switch = []
for i in range(m):
    ks = list(map(int,input().split()))
    ls.append(ks)
    for j in range(1,ks[0]+1):
        if not ks[j] in switch:
            switch.append(ks[j])
p = list(map(int,input().split()))

#print(switch)
pattern = []
for i in range(2**len(switch)):
    pattern.append(list(bin(i)[2:].zfill(len(switch))))
#print(pattern)
ans = 0

for i in pattern:
    turn = []
    count = 0
    on = 0
    for j in range(len(switch)):
        if i[j] == '1':
            turn.append(switch[j])
    #print(turn)
    for k in range(m):
        for l in range(1,ls[k][0]+1):
            if ls[k][l] in turn:
                count += 1
        if count % 2 == p[k]:
            on += 1
    if on == m:
        ans += 1
            
print(ans)