def iterator(n):
    for i in range(pow(2, n)):
        res = []
        for s in range(n):
            if i & (1 << s):
                res.append(s)
        if len(res) > 0:
            yield res


n, m = map(int, input().split())
sws = [[0] * n for _ in range(m)]

for i in range(m):
    k, *s = map(int, input().split())
    for si in s:
        sws[i][si - 1] = 1

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

ans = 0
for on in iterator(n):
    state = [0 for _ in range(m)]
    for ln, sw in enumerate(sws):
        count = 0
        for o in on:
            if sw[o] == 1:
                count += 1
        if count > 0 and count % 2 == p[ln]:
            state[ln] = 1
    if state.count(1) == m:
        ans += 1

print(ans)


