n,m=map(int,input().split())
s=[]
count=0
for i in range(m):
    tmp=list(map(int,input().split()))
    s.append(tmp[1:])

p=list(map(bool,input().split()))
p=list(map(lambda x:not x,p))

for i in range(2**n):
    tmp_p=p[:]#shallow copy
    for j in range(n):
        if i >> j & 1:
            for k in range(m):
                if j+1 in s[k]:
                    tmp_p[k]^=True#toggle

    if all(tmp_p):
        count+=1

print(count)
