n, m = map(int, input().split())
k = [list(map(int, input().split()))[1:] for _ in range(m)]
p = list(map(int, input().split()))
count = 0

for i in range(n**2):
    for l in range(m):
        tmp = 0
        for j in range(n):
            if ((i >> j) & 1)and j+1 in k[l]:
                tmp += 1
        print('t', l, tmp)
        if tmp %2 != p[l]:
            break
    else:
        count += 1
print(count)
            