N,M = list(map(int,input().split()))

data=[]
for i in range(M):
    K,*S = list(map(int,input().split()))
    data.append(S)
p = list(map(int,input().split()))

counter = 0

for i in range(2**M):
    light = [0]*M
    for j in range(M):
        if i%2**j:
            for k in data[j]:
                light[k-1] = light[k-1]+1
    light = [x%2 for x in light]
    if light == p:
        counter += 1

print(str(counter))