N, M = map(int, raw_input().split())
ks_list = []
p_list = []
for i in range(M):
    ks_list.append(map(int, raw_input().split()))
p_list.append(map(int, raw_input().split()))

ans_count = 0
for i in range(2**N):
    
    cond = 0
    switch_list = [0]*N
    for j in range(N):
        switch_list[j]=(i>>j)&1

    for m in range(M):
        tmp_count = 0
        for k in range(ks_list[m][0]):
            if switch_list[ks_list[m][1+k]-1] == 1:
                tmp_count = tmp_count + 1

        if p_list[0][m] == (tmp_count % 2):
            cond = 1
        else:
            cond = 0
            break
    if cond == 1:
        ans_count = ans_count + 1
print ans_count
