import itertools as it
N,M = map(int,input().split())
slk = []
for _ in range(M):
    slk.append(list(map(int,input().split())))
p = list(map(int,input().split()))
#print(N,M)
#print(slk)
#print(p)

s = [i+1 for i in range(N)]
cb = 0
for i in range(1,N+1):
    cmbi = list(it.combinations(s, i))
    #print('i,cmbi:',i,cmbi)
    for ccmb in cmbi:
        for j,slki in enumerate(slk):
            g = 0
            #print('slki',slki)
            for k in range(slki[0]):
                if slki[k+1] in ccmb:
                    g += 1
            #print('g,p:',g,p[j])
            if g%2 == p[j]:
                pass
            else:
                #print('error')
                break
        else:
            cb += 1
            #print('add succ;',cb)
print(cb)