n, m = map(int ,input().split())
s = [list(map(int, input().split())) for _ in range(m)]
p = [int(i) for i in input().split()]

ans = 0
for i in range(1 << n):
    check = []
    for j in range(n):
        if i >> j & 1:
            check.append(j)

    check = set(check)

    flag = True
    for j in range(m):
        tmp = 0
        for k in range(1, s[j][0]):
            if s[j][k] in check:
                tmp += 1

        if tmp % 2 != p[j]:
            flag = False
            break

    if flag == True:
        ans += 1

print(ans)




