def roop(onoff, n):
    swit[n] = onoff
    if n == N-1:
        cur = 0
        flag = True
        for i in range(M):
            for s in range(1,data[i][0]+1):
                cur += swit[data[i][s]-1]
            if cur%2 != p[i]:
                flag = False
                break
        if flag:
            return 1
        else:
            return 0
    else:
        return roop(0,n+1) + roop(1,n+1)
        

N,M = map(int,input().split())
data = [[] for i in range(M)]
for i in range(M): data[i] = list(map(int,input().split()))
p = list(map(int,input().split()))

swit = [0]*N
print(roop(0,0) + roop(1,0))