from copy import deepcopy
n, m = map(int, raw_input().split())
S = []
for _ in range(m):
    line = map(int, raw_input().split())
    S.append(line[1:])
P = map(int, raw_input().split())
perms = [[0] * n]
for i in range(n):
    for j in range(len(perms)):
        p2 = deepcopy(perms[j])
        p2[i] = 1
        perms.append(p2)
ways = 0
for perm in perms:
    satisfy = True
    for k in range(m):
        count = 0
        for s in S[k]:
            if perm[s-1] == 1:
                count += 1
        if count % 2 != P[k]:
            satisfy = False
            break
    if satisfy:
        ways += 1
print ways