import sys  
input = sys.stdin.readline

N, M = list(map(int, input().split()))

sk = []
for i in range(M):
    s = list(map(int, input().split()))
    sk.append(s)

p = list(map(int, input().split()))

ans_sum = 0
pre_ = 0
for i1 in [0, 1]:
    for i2 in [0, 1]:
        for i3 in [0, 1]:
            for i4 in [0, 1]:
                for i5 in [0, 1]:
                    for i6 in [0, 1]:
                        for i7 in [0, 1]:
                            for i8 in [0, 1]:
                                for i9 in [0, 1]:
                                    for i10 in [0, 1]:
                                        p_ = [i1, i2, i3, i4, i5, i6, i7, i8, i9, i10]
                                        pre = p_[:N]
                                        if pre == pre_:
                                            break
                                        ans_ = 0
                                        for q in range(M):
                                            ans = 0
                                            for r in range(sk[q][0]):
                                                ans += pre[sk[q][r+1]-1]
                                            if ans > 0 and ans%2 == p[q]:
                                                ans_ +=1
                                        
                                        if ans_ == M:
                                            ans_sum += 1

                                        pre_ = pre

print(ans_sum)