N, M = map(int, input().split())
l=[]
for i in range(M):
    L = list(map(int, input().split()))
    l.append(l[1:]) 
s=list(map(int, input().split()))
c=0
for i in range(2**N):
    d =True
    for j in range(M):
        a = 0
        for k in range(N):
            if ((i >>k)&1 == 1) and (k+1 in l[j]):
                a += 1
        if a%2 == s[j]:
            continue
        else:
            d = False
            break
    if d is True:
        c += 1
print(c)