#!/usr/bin/env python3
#ABC128 C

N,M = map(int,input().split())

S = [list(map(int,input().split())) for _ in range(M)]
P = list(map(int,input().split()))
K = [S[i][0] for i in range(M)]
#print("S",S)
#print("P",P)
#print("K",K)

ans = 0

for i in range(2**N):
    switch = [0]*N
    for j in range(M):
        if i >> j  & 1:
            switch[j] = 1
    tmp = 0
    flag = 0
    #print(switch)
    for j in range(M):
        for k in range(1,K[j]+1):
            if switch[S[j][k] - 1] == 1:
                tmp += 1#switch on の数
        #print("tmp",tmp)
        if tmp % 2 != P[j]:
            flag = 1
            break
    if not flag:
        ans += 1
print(ans)