N,M = map(int, input().split())
ks = [[int(i) for i in input().split()] for j in range(M)]
p = [int(i) for i in input().split()] 

l = max(ks[0])
for m in range(1,M):
    l = max(l,max(ks[m]))

lis_swi = [[] for i in range(l)]

for m in range(M):
    for s in ks[m][1:]:
        lis_swi[s-1].append(m)


ans = 0

for i in range(1 << l):
    cnt_on = [0]*M
    for j in range(l):
        if ((i >> j) & 1) == 1:
            for m in lis_swi[j]:
                cnt_on[m] +=1

    f = True
    for m in range(M):
        if cnt_on[m]%2 != p[m]:
            f = False
            break
    
    if f:
        ans += 1


print(ans)