from itertools import product

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

bulb = {}
for i in range(1, m+1):
    k_s = list(map(int, input().split()))
    bulb[i] = k_s[1:]

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

count = 0
for item in product([0, 1], repeat=n):
    on = [ind+1 for ind, status in enumerate(item) if status == 1]
    for k, v in bulb.items():
        if p[i-1] != len(set(v).intersection(set(on))) % 2:
            break
    else:
        count += 1

print(count)

