N,M=map(int,input().split())
l=[]
for i in range(M):
    *a,=map(int,input().split())
    l.append(a[1:])
*p,=map(int,input().split())

ans=0
for t in range(2**N):
    tmp=[(t>>s)&1 for s in range(N)]
    light=True
    for i in range(M):
        cnt=0
        for j in range(len(l[i])):
            if tmp[l[i][j]-1]=='1':
                cnt+=1
            if cnt%2!=p[i]%2:
                light=False
                break
    if light:
        ans+=1

print(ans)