import itertools

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

for i in range(M):
    string_k = input().split()
    ls_k.append(list(map(int, string_k)))
    del ls_k[i][0]

string_p = input().split()
ls_p = list(map(int, string_p))

ans = 0


def S_gen(N):
    S_pat = []
    set_lis = list(range(1, N+1))
    for i in range(1, N+1):
        S_pat.extend(list(itertools.combinations(set_lis, i)))
    return S_pat


S_pat = S_gen(N)


count = 0

for i in S_pat:
    correct = True
    for j in range(M):
        check = []
        # print(set(ls_k[j][:]))
        # print(set(i))
        check = list(set(ls_k[j][:]) & set(i))
        # print(check)
        if len(check) % 2 != ls_p[j]:
            correct = False
    # print(correct)
    if correct:
        count += 1

print(count)
