n, m = map(int, input().split())
k_list = [list(map(int, input().split()))[1:] for _ in range(m)]
p_list = list(map(int, input().split()))

ans = 0
for bit in range(2**n):
    check = True
    for k, p in zip(k_list, p_list):
        if check:
            count = 0
            for i in range(n):
                if bit & (1 << i):
                    if i in k:
                        count += 1
            if (count%2) != p:
                check = False
    if check:
        ans += 1
        
print(ans)