N, M = map(int, input().split())
S = []
for _ in range(M):
    s = list(map(int, input().split()))
    S.append(s[1:])
P = list(map(int, input().split()))
SS = [0] * N

ans = 0
for i in range(1, 2**N):
    num = 0
    for j in range(N):
        if (i >> j) & 1 == 1:
            SS[j] = 1
    flg = True
    for j, s in enumerate(S):
        num = 0
        for e in s:
            if SS[e-1] == 1:
                num += 1
        if num % 2 != P[j]:
            flg = False
            break
    if flg:
        ans += 1
    SS = [0] * N   
print(ans)