from itertools import combinations_with_replacement
from operator import itemgetter

N, M = map(int, input().split())
lights = list(tuple(map(int, input().split())) for _ in range(M))
cons = list(map(int, input().split()))

ans = 0
for switch in combinations_with_replacement(range(2), r=N):
    reminders = []
    for idx, light in enumerate(lights):
        f = itemgetter(*map(lambda x: x - 1, light[1:]))
        if isinstance(f(switch), int):
            s = f(switch)
        else:
            s = sum(f(switch))
        reminders.append(s % 2)
    if cons == reminders:
        ans += 1
print(ans)
