from itertools import product

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

ks = [list(map(int,input().split())) for _ in range(M)]
p = list(map(int,input().split()))

#偶数奇数の判定に使う
cnt_p = 0
ans = 0

#それぞれのスイッチの状態について検証を行う
for i in product(range(2), repeat=N):
    cnt = 0
    #電灯ごとの点滅を調べる
    for j in range(M):
        for k in ks[j][1:]:
            cnt_p += i[k-1]
        if cnt_p %2 == p[j]:
            cnt += 1
        else:
            break
    #全てつくならansに+1
    if cnt == M:
        ans += 1

print(ans)