n,m=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(m)]
p=list(map(int,input().split()))
c=0
for i in range(2**n):
    xi=format(i,'b').zfill(n)
    light_count=0
    for j in range(m):
        xl=[i for i, x in enumerate(xi) if x == '1']
        c1=0
        for k in range(1,len(l[j])):
            if l[j][k] in xl:c1+=1
        if c1%2==p[j]:light_count+=1
    if light_count==m:c+=1
print(c)