

import itertools
N, M = map(int, input().split())
ks = [[int(i) for i in input().split()] for _ in range(M)]
p = list(map(int, input().split()))


k = []
s = []
for i in range(M):
    k.append(ks[i][0])
    s.append(ks[i][1:])

result = 1
for i in range(M):
    j = 1
    temp = 0
    while j < k[i]+1:
        c = itertools.combinations(s[i], j)
        for v in c:
            li = list(v)
            if p[i] == len(li) % 2:
                temp += 1
        j += 1
    result *= temp
print(result)
