def main():
    N,M = map(int,input().split())
    switches = []
    for i in range(M):
        switches.append(list(map(int,input().split()))[1:])
    P = list(map(int,input().split()))
    ans = 0
    for i in range(2**N):
        on = [False]*N
        for j in range(N):
            if (2**j) & i :
                on[j] = True

        for j in range(M):
            count = 0
            for s in switches[j]:
                if on[s-1]:
                    count += 1
            if count % 2 != P[j]:
                break
            else:
                continue
            break
        else:
            ans += 1
    print(ans)










main() def main():
    N,M = map(int,input().split())
    switches = []
    for i in range(M):
        switches.append(list(map(int,input().split()))[1:])
    P = list(map(int,input().split()))
    ans = 0
    for i in range(2**N):
        on = [False]*N
        for j in range(N):
            if (2**j) & i :
                on[j] = True

        for j in range(M):
            count = 0
            for s in switches[j]:
                if on[s-1]:
                    count += 1
            if count % 2 != P[j]:
                break
            else:
                continue
            break
        else:
            ans += 1
    print(ans) main N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M switches = [] switches [] for i in range(M):
        switches.append(list(map(int,input().split()))[1:])
     i range(M) range M switches.append(list(map(int,input().split()))[1:]) switches.append switches 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 = list(map(int,input().split())) P list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split ans = 0 ans 0 for i in range(2**N):
        on = [False]*N
        for j in range(N):
            if (2**j) & i :
                on[j] = True

        for j in range(M):
            count = 0
            for s in switches[j]:
                if on[s-1]:
                    count += 1
            if count % 2 != P[j]:
                break
            else:
                continue
            break
        else:
            ans += 1
     i range(2**N) range 2**N 2 N on = [False]*N on [False]*N [False] False N for j in range(N):
            if (2**j) & i :
                on[j] = True

         j range(N) range N if (2**j) & i :
                on[j] = True

         (2**j) & i 2**j 2 j i on[j] = True on[j] on j True for j in range(M):
            count = 0
            for s in switches[j]:
                if on[s-1]:
                    count += 1
            if count % 2 != P[j]:
                break
            else:
                continue
            break
        else:
            ans += 1
     j range(M) range M count = 0 count 0 for s in switches[j]:
                if on[s-1]:
                    count += 1
             s switches[j] switches j if on[s-1]:
                    count += 1
             on[s-1] on s-1 s 1 count += 1 count 1 if count % 2 != P[j]:
                break
            else:
                continue
             count % 2 != P[j] count % 2 count 2 P[j] P j break continue break ans += 1 ans 1 print(ans) print ans main() main def main():
    N,M = map(int,input().split())
    switches = []
    for i in range(M):
        switches.append(list(map(int,input().split()))[1:])
    P = list(map(int,input().split()))
    ans = 0
    for i in range(2**N):
        on = [False]*N
        for j in range(N):
            if (2**j) & i :
                on[j] = True

        for j in range(M):
            count = 0
            for s in switches[j]:
                if on[s-1]:
                    count += 1
            if count % 2 != P[j]:
                break
            else:
                continue
            break
        else:
            ans += 1
    print(ans) def main():
    N,M = map(int,input().split())
    switches = []
    for i in range(M):
        switches.append(list(map(int,input().split()))[1:])
    P = list(map(int,input().split()))
    ans = 0
    for i in range(2**N):
        on = [False]*N
        for j in range(N):
            if (2**j) & i :
                on[j] = True

        for j in range(M):
            count = 0
            for s in switches[j]:
                if on[s-1]:
                    count += 1
            if count % 2 != P[j]:
                break
            else:
                continue
            break
        else:
            ans += 1
    print(ans) main
def main():
    N,M = map(int,input().split())
    switches = []
    for i in range(M):
        switches.append(list(map(int,input().split()))[1:])
    P = list(map(int,input().split()))
    ans = 0
    for i in range(2**N):
        on = [False]*N
        for j in range(N):
            if (2**j) & i :
                on[j] = True

        for j in range(M):
            count = 0
            for s in switches[j]:
                if on[s-1]:
                    count += 1
            if count % 2 != P[j]:
                break
            else:
                continue
            break
        else:
            ans += 1
    print(ans)










main()