from itertools import combinations


def count_can_light(N, bulbs, ps):
    count = 0
    for i in range(1, N+1):
        for combi in combinations(range(1, N+1), i):
            is_ok = True
            for n, switches in enumerate(bulbs):
                if len(set(combi) & set(switches)) % 2 != ps[n]:
                    is_ok = False
                    break
            if is_ok:
                count += 1
    return count


def main():
    N, M = map(int, input().split())
    bulbs = []
    for _ in range(M):
        values = list(map(int, input().split()))
        bulbs.append(values[1:])
    ps = list(map(int, input().split()))
    print(count_can_light(N, bulbs, ps))
    

main()