def solve(switch_state, depth):
    if depth == 0:
        yield switch_state
    else:
        yield from solve(switch_state + [0], depth - 1) # off
        yield from solve(switch_state + [1], depth - 1) # on

n, m = map(int, input().split())

k_list = []
s_matrix = []

for _ in range(0, m):
    tmp = list(map(int, input().split()))
    k_list.append(tmp[0])
    s_matrix.append(tmp[1:])

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

switch_to_light = {}
for i, s_list in enumerate(s_matrix):
    for s in s_list:
        if s in switch_to_light:
            switch_to_light[s].append(i)
        else:
            switch_to_light[s] = [i]

count = 0
for switch_state in solve([], max(switch_to_light.keys())):
    is_all_light_on = True 
    for i, s_list in enumerate(s_matrix):
        sum_of_on = 0
        for s in s_list:
            sum_of_on = sum_of_on + switch_state[s - 1]
        if sum_of_on % 2 != p_list[i]:
            is_all_light_on = False
            break
    if is_all_light_on:
        count = count + 1

print(count)

