N,M = map(int, input().rstrip().split())
k_s = [list(map(int, input().rstrip().split())) for _ in range(M)]
for i in range(M):
    k_s[i].pop(0)
P = list(map(int, input().split()))
#on=1,off=0
count = 0
counter = 0
limit = 2**N
for i in range(2):
    for j in range(2):
        for k in range(2):
            for l in range(2):
                for m in range(2):
                    for n in range(2):
                        for o in range(2):
                            for p in range(2):
                                for q in range(2):
                                    for r in range(2):
                                        counter += 1
                                        stats = [r,q,p,o,n,m,l,k,j,i]
                                        stats = stats[:N]
                                        index = 0
                                        flg = True
                                        for s in k_s:
                                            sums = 0
                                            for t in s:
                                                sums += stats[t-1]
                                            rem = sums % 2
                                            if rem == P[index]:
                                                flg = False
                                                break
                                        if flg:
                                            count += 1
                                        if limit == counter:
                                            print(count)