def i_input(): return int(input())


def i_map(): return map(int, input().split())


def i_list(): return list(i_map())


def i_row_list(n): return [i_list() for _ in range(n)]


def bit_search(n):
    bit_ans = []
    for i in range(2 ** n):
        temp = []
        for j in range(n):
            if ((i >> j) & 1):
                temp.append(1)
            else:
                temp.append(0)
        bit_ans.append(temp)
    return bit_ans


def light_check(switchpattern, lightswitches, onstat):
    cnt = 0
    for i in range(len(switchpattern)):
        if switchpattern[i] == 1 and lightswitches[i] == 1:
            cnt += 1
    if cnt % 2 == onstat:
        return 1
    else:
        return 0


n, m = i_map()
kkk = i_row_list(m)
onstates = i_list()
kkk_row = []
for i in range(m):
    tmp = [0] * n
    for j in kkk[i]:
        if j != 0:
            tmp[j - 1] = 1
    kkk_row.append(tmp)

switchpatterns = bit_search(n)
ans = 0
for switchpattern in switchpatterns:
    cnt = 0
    for i in range(m):
        cnt += light_check(switchpattern, kkk_row[i], onstates[i])
    if cnt == m:
        ans += 1

print(ans)
