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 = 0
    for k, p in zip(k_list, p_list):
        count = 0
        for i in range(n):
            if bit & (1 << i):
                if i in k:
                    count += 1
        if (count%2) == p:
            check += 1
    if check == m:
        ans += 1
        
print(ans)