# -*- coding: utf-8 -*-

N, M = map(int, input().split())
l_list = []
for _ in range(M):
    data = list(map(int, input().split()))[1:]
    l_list.append(sum(2**(x-1) for x in data))

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

# ビット全探索
count = 0
for sw in range(2**N):
    for l, p in zip(l_list, p_list):
        A = l & sw
        A = (0x55555555 & A) + ((0xAAAAAAAA & A)>>1)
        A = (0x33333333 & A) + ((0xCCCCCCCC & A)>>2)
        A = (0x0f0f0f0f & A) + ((0xf0f0f0f0 & A)>>3)
        A = (0x00ff00ff & A) + ((0xff00ff00 & A)>>4)
        A = (0x0000ffff & A) + ((0xffff0000 & A)>>5)
        if A % 2 != p:
            break
    else:
        count += 1
print(count)