def is_all_lighting(switch_patten, s_info_list, p_list):
    for i in range(len(s_info_list)):
        s_info = s_info_list[i]
        on_count = 0
        for s in s_info['s_list']:
            on_count += switch_patten // (2 ** (s - 1)) % 2
        if on_count % 2 != p_list[i]:
            return False
    return True


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

for _ in range(M):
    val_list = list(map(int, input().split()))
    s_info_list.append({
        'k': val_list[0],
        's_list': val_list[1:]
    })
p_list = list(map(int, input().split()))

count = 0

for pattern in range(1, 2 ** N):
    if is_all_lighting(pattern, s_info_list, p_list):
        count += 1

print(count)
