N, M = map(int, input().split())
KS = [list(map(int, input().split())) for _ in range(M)]
P = list(map(int, input().split()))

switch = []
for i in range(N**2):
    tmp = []
    for j in range(N):
        if (i >> j) & 1:
            tmp.append(j+1)
    switch.append(tmp)

cnt = 0
for s in switch:
    judge = True
    for idx,ks in enumerate(KS):
        kcnt = 0
        for k in ks[1:]:
            if k in s:
                kcnt += 1
        if kcnt % 2 == P[idx]:
            continue
        judge = False
        break
    if judge:
        cnt += 1

print(cnt)