N, M = list(map(int, input().split()))

k_list = []
s_list = []
for i in range(M):
    k_s = list(map(int, input().split()))
    k_list.append(k_s[0])
    s_list.append(k_s[1:])

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

ans = 0

for i in range(1 << N):
    all_list = True
    for j in range(M):
        n = 0
        for k in s_list[j]:
            n += bool(i & (1 << k))
        if n % 2 != p_list[j]:
            all_list = False
            break
    ans += all_list

print(ans)