import itertools
count =0
ans=0
n,m = map(int,input().split())
pattern = list(itertools.permutations(range(2), n))
pattern.append([0]*m)
pattern.append([1]*m)

lists =[]
switches = [1]*n
onoff = [0]*m
for i in range(m):
    lists.append(list(map(int,input().split())))
key_value = list(map(int,input().split()))
for l in pattern:
    switches = list(l)
    for j in range(m):
        for k in range(int(lists[j][0])):
            if switches[k] == 1:
                count += 1
        if count %2 == key_value[j]:
            onoff[j] = 1
        else:
            break
    if not 0 in onoff:
        ans += 1

print(ans)











