#!/usr/bin/env python3

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    N, M = MII()
    s = []
    for _ in range(M):
        s.append(list(map(int, input().split()))[1:])
    p = LII()

    ans = 0
    for i in range(2**N, 2**(N+1)):
        b = bin(i)[3:]
        t = [0] * M
        for j, sj in enumerate(s):
            for k, bi in enumerate(list(b)):
                if bi == '1' and k+1 in sj:
                    t[j] += 1
            if t[j] % 2 != p[j]:
                ans -= 1
                break
        ans += 1

    print(ans)

if __name__ == '__main__':
    main() def II(): return int(input()) II def MII(): return map(int, input().split()) MII def LII(): return list(map(int, input().split())) LII def main():
    N, M = MII()
    s = []
    for _ in range(M):
        s.append(list(map(int, input().split()))[1:])
    p = LII()

    ans = 0
    for i in range(2**N, 2**(N+1)):
        b = bin(i)[3:]
        t = [0] * M
        for j, sj in enumerate(s):
            for k, bi in enumerate(list(b)):
                if bi == '1' and k+1 in sj:
                    t[j] += 1
            if t[j] % 2 != p[j]:
                ans -= 1
                break
        ans += 1

    print(ans) main N, M = MII() N MII() MII M s = [] s [] for _ in range(M):
        s.append(list(map(int, input().split()))[1:])
     _ range(M) range M s.append(list(map(int, input().split()))[1:]) s.append s append list(map(int, input().split()))[1:] (map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split 1: 1 p = LII() p LII() LII ans = 0 ans 0 for i in range(2**N, 2**(N+1)):
        b = bin(i)[3:]
        t = [0] * M
        for j, sj in enumerate(s):
            for k, bi in enumerate(list(b)):
                if bi == '1' and k+1 in sj:
                    t[j] += 1
            if t[j] % 2 != p[j]:
                ans -= 1
                break
        ans += 1

     i range(2**N, 2**(N+1)) range 2**N 2 N 2**(N+1) 2 N+1 N 1 b = bin(i)[3:] b bin(i)[3:] (i) bin i 3: 3 t = [0] * M t [0] * M [0] 0 M for j, sj in enumerate(s):
            for k, bi in enumerate(list(b)):
                if bi == '1' and k+1 in sj:
                    t[j] += 1
            if t[j] % 2 != p[j]:
                ans -= 1
                break
         j sj enumerate(s) enumerate s for k, bi in enumerate(list(b)):
                if bi == '1' and k+1 in sj:
                    t[j] += 1
             k bi enumerate(list(b)) enumerate list(b) list b if bi == '1' and k+1 in sj:
                    t[j] += 1
             bi == '1' and k+1 in sj bi == '1' bi '1' k+1 in sj k+1 k 1 sj t[j] += 1 t[j] t j 1 if t[j] % 2 != p[j]:
                ans -= 1
                break
         t[j] % 2 != p[j] t[j] % 2 t[j] t j 2 p[j] p j ans -= 1 ans 1 break ans += 1 ans 1 print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def LII(): return list(map(int, input().split())) def LII(): return list(map(int, input().split())) LII def MII(): return map(int, input().split()) def MII(): return map(int, input().split()) MII def main():
    N, M = MII()
    s = []
    for _ in range(M):
        s.append(list(map(int, input().split()))[1:])
    p = LII()

    ans = 0
    for i in range(2**N, 2**(N+1)):
        b = bin(i)[3:]
        t = [0] * M
        for j, sj in enumerate(s):
            for k, bi in enumerate(list(b)):
                if bi == '1' and k+1 in sj:
                    t[j] += 1
            if t[j] % 2 != p[j]:
                ans -= 1
                break
        ans += 1

    print(ans) def main():
    N, M = MII()
    s = []
    for _ in range(M):
        s.append(list(map(int, input().split()))[1:])
    p = LII()

    ans = 0
    for i in range(2**N, 2**(N+1)):
        b = bin(i)[3:]
        t = [0] * M
        for j, sj in enumerate(s):
            for k, bi in enumerate(list(b)):
                if bi == '1' and k+1 in sj:
                    t[j] += 1
            if t[j] % 2 != p[j]:
                ans -= 1
                break
        ans += 1

    print(ans) main def II(): return int(input()) def II(): return int(input()) II
#!/usr/bin/env python3

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    N, M = MII()
    s = []
    for _ in range(M):
        s.append(list(map(int, input().split()))[1:])
    p = LII()

    ans = 0
    for i in range(2**N, 2**(N+1)):
        b = bin(i)[3:]
        t = [0] * M
        for j, sj in enumerate(s):
            for k, bi in enumerate(list(b)):
                if bi == '1' and k+1 in sj:
                    t[j] += 1
            if t[j] % 2 != p[j]:
                ans -= 1
                break
        ans += 1

    print(ans)

if __name__ == '__main__':
    main()
