N, M = map(int, input().split())
s = []
k = []

for _ in range(M):
    tmp = list(map(int, input().split()))
    k.append(tmp.pop(0))
    s.append(tmp)
p = list(map(int, input().split()))
counter = 0

for bit in range(1 << N):
    tmp = 0
    hantei = True
    for n1, j in enumerate(s):
        for i in j:
            if(bit & (1 << (i-1))):
                tmp += 1
        if(tmp % 2 != p[n1]):
            hantei = False
    if(hantei == True):
        counter += 1

print(counter)
