n, m = map(int, input().split())

k = []

for i in range(m):
    k.append(list(map(int, input().split())))

p = list(map(int, input().split()))

ans = 0

for i in range(2**n):
    switch = [0] * n
    for j in range(n):
        if i >> j & 1 == 1:
            switch[j] += 1
    cntt = 0
    for j in range(m):
        cnt = 0
        for s in range(1, k[j][0]+1):
            if switch[s-1] == 1:
                cnt += 1
        if cnt%2 != p[j]:
            cntt += 1
            break
    if cntt == 0:
        ans += 1

print(ans)