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

bulbs = []
for m in range(M):
    ks = map(int, input().split())
    bulbs.append(list(ks)[1:])

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

result = 0
for m in range(2**N):
    switches = list(map(int, list(str(bin(m))[2:])))
    switches = [0]*(N-len(switches)) + switches

    flag = True
    for idx, bulb in enumerate(bulbs):
        count = 0
        for switch in range(len(bulb)):
            count += switches[switch]
        if count % 2 != P[idx]:
            flag = False
            break
    if flag:
        result += 1
print(result)
