N,M = map(int,input().split())
switch = [0]*N
for m in range(M):
    ss = list(map(int, input().split()))[1:]
    for s in ss:
        switch[s-1] |= 2**m
li = 0
for index,p in enumerate(list(map(int, input().split()))):
    if p==1: li = 2**index
answer = 0
for n in range(2**N):
    l = 0
    for s in range(N):
        if (n>>s)&1: l^=switch[s]
    if p==l: answer+=1
print(answer)