L = []
S = []
N, M = map(int, input().split())
cnt = 0
ans = 0
for i in range(M):
    l = list(map(int, input().split()))
    L.append(l)
p = list(map(int, input().split()))

for j in range(2**N):
    switch = [0]*N
    for k in range(N):
        if (j >> k) & 1:
            switch[k-1]=1
    S.append(switch)
    #ここまでで全パターン
#あるパターンにおいて全点灯しているか？
print(S)

for i in range(2**N):
    I = [0]*M
    cnt = 0
    for k in range(M):
        for x in range(1, len(L[k])):
            if S[i][L[k][x]-1]==1:
                I[k]+=1
    for i in range(M):
        if I[i]%2==p[i]:
            cnt +=1
    if cnt == M:
        ans +=1
print(ans)