def f_c():
    n, m = map(int, input().split())
    l = []
    for _ in range(m):
        _, *s = map(lambda x: int(x)-1, input().split())
        sb = 0
        for si in s:
            sb |= 1<<si
        l.append(sb)
    *p, = map(int, input().split())

    a, c = 0, 0
    for i in range(1, 1<<n):
        for j, sb in enumerate(l):
            if bin(i&sb).count("1")%2!=p[j]:
                break
            else:
                c += 1
        a = a+1 if c==m else a
        c = 0
    print(a)

if __name__ == "__main__":
    f_c()
