#C
#switch: 1,2,...N
#bulb: 1,...M
#bulb_i is connected to k_i switches: si1, si2,...sik_i
#bulb_i = 1 iff sum(si1,...sik_i) % 2 == p_i
#p_i = {0, 1}
N, M = map(int,input().split())
maxsig = 2**N
mask_l = []
for _ in range(M):
    li = input().split()
    k = li[0]
    s = list(map(int,li[1:])) #list
    mask = 0
    for itm in s:
        mask += 2**(itm-1)
    mask_l.append(mask)
p = list(map(int,input().split()))
ans = 0
flg = False
for num in range(maxsig):
    for b in range(M):
        mask = mask_l[b]
        dp = p[b]
        if sum(map(int,list(bin(num & mask)[2:]))) // 2 != dp:
            flg = True
            break
    if flg == False : ans += 1
    else: flg = False
print(ans)
