#入力取得
N, M = map(int, input().split())

k=[]
for i in range(M):
    tmp = list(map(int, input().split()))
    k.append(tmp)

p = list(map(int, input().split()))


result = 0


if N == 1 and M == 1:
    print(1)


else:
    for i in range(2**N):
        bin_str = format(i, 'b')
        bin_str = bin_str.zfill(N)

        flag = 1

        for j in range(len(k)):

            tmp_sum = 0


            for l in range(len(k[j])):
                if l != 0:
                    tmp_sum += int(bin_str[l-1])

            equal_p = tmp_sum % 2

            if equal_p % 2 == p[j]:
                flag = 1

            if equal_p % 2 != p[j]:
                flag = 0
                break

        if  flag == 0:
            continue

        if flag == 1:
            result += 1
            # print(bin_str)



    print(result)
