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

S = []
for i in range(M):
    S.append(set([int(v) for v in input().split()][1:]))
P = [int(v) for v in input().split()]

limit = int('1' * N, 2)
res = 0
for j in range(limit + 1):
    on_idx = set()
    for ki, k in enumerate(list(('{:0' + str(N) + 'b}').format(j))):
        if k == '1':
            on_idx.add(ki)

    cnt = 0
    for i in range(M):
        cnt += int(len(S[i].intersection(on_idx)) % 2 == P[i])

    if cnt == M:
        res += 1
print(res)
