n, m = map(int, input().split())
LST = []
for _ in range(m):
    lst = list(map(int, input().split()))
    lst = lst[1:]
    lst = map(lambda x: x - 1, lst)
    LST.append(list(lst))

p = list(map(int, input().split()))
cnt = 0
for i in range(1, 2 ** n):
    tmp_denkyuu = 0
    for j in range(m):
        tmp_bit = 0
        s_cs = LST[j]
        for s_c in s_cs:
            if (i >> (n - 1 - s_c)) & 1:
                tmp_bit += 1
        if tmp_bit % 2 == p[j]:
            tmp_denkyuu += 1
    if tmp_denkyuu == m:
        cnt += 1

print(cnt)