import sys
input = sys.stdin.readline
import itertools

N, M = [int(item) for item in input().split()]

k = []
s = []
for i in range(M):
    items = [int(item) for item in input().split()]
    k.append(items[0])
    s.append(items[1:])

p = [int(item) for item in input().split()]

count = 0

for pat in itertools.product([0, 1], repeat=N):
    for l in range(M):
        ons = sum([pat[item - 1] for item in s[l]])
        if ons % 2 != p[i] % 2:
            break
    else:
        count += 1

print(count)
