n, m = map(int, input().split())

lis = []
for _ in range(m):
    new = list(map(int, input().split()))
    lis.append(new[1:])

plist = list(map(int, input().split()))

res = 0
for i in range(2**n):
    cou = [0 for k in range(m)]
    binary = bin(i)[2:]
    for j in range(len(binary)):
        if binary[j] == '1':
            for k in range(len(lis)):
                if j + 1 in lis[k]:
                    cou[k] += 1 
    if all((cou[x] - plist[x])%2 == 0 for x in range(m)):
        res += 1
print(res)