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

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

count = 0
for i in range(2**n):
    flag = True
    for j in range(m):
        if not([1 & (i >> k-1) for k in s[j]].count(1) % 2 == p[j]):
            flag = False
    if flag:
        count += 1
print(count)



