n, m = map(int, input().split())
switches = []
for i in range(m):
    switches.append(list(map(int, input().split())))

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

# print("switches : {}".format(switches))
# print("p : {}".format(p))

switches_pattern = []
for i in range(2**n):
    if i == 0:
        continue
    switches_pattern.append(list(map(int, format(i, "b").zfill(n))))

# print(switches_pattern)

result = 0
for pattern in switches_pattern:
    light_bulb = True
    for i in range(m):
        bulb_count = 0
        for bulb_index in switches[i][1:]:
            if pattern[bulb_index - 1] == 1:
                bulb_count += 1
        if bulb_count % 2 == p[i]:
            pass
        else:
            light_bulb = False

    if light_bulb:
        result += 1

print(result)