N, M = map(int, input().split())
K_S = [0]*N
for i in range(N):
    K_S[i] = list(map(int, input().split()))
p = list(map(int, input().split()))

ans = 0
for i in range(2 ** N):
    switch_onoff = [0]*N
    tmp = i
    for j in range(N):
        if tmp % 2 == 1:
            switch_onoff[j] = 1
        tmp = tmp // 2
    flag = True
    for j in range(M):
        count = 0
        for k in range(1, K_S[j][0] + 1):
            count += switch_onoff[K_S[j][k] - 1]
        if count % 2 != p[j]:
            flag = False
            break
    if flag:
        ans += 1
print(ans)