n, M = map(int, input().split())
s = [list(map(int, input().split()))[1:] for m in range(m)]
p = list(map(int, input().split()))

for i in range(2 ** n):
    for m in range(M):
        switch = 0
        for j in range(n):
            if (i >> j) & 1:
                if j + 1 in s[m]:
                    switch += 1
        if switch % 2 != p[m]:
            break
    else:
        count += 1
print(count)