from itertools import product
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,M = map(int, readline().split())
    S = [[int(i) for i in readline().split()] for _ in range(M)]
    P = [int(i) for i in readline().split()]

    ans = 0
    A = [[0, 1] for _ in range(N)]
    for pattern in product(*A):
        on = []
        for s in S:
            tmp = 0
            for i in range(s[0]):
                tmp += pattern[i]
            on.append(tmp % 2)

        if on == P:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()
