N,M = map(int,input())
K = []
S = []
for i in range(M):
    list = input().split()
    K.append(int(list[0]))
    S.append(map(int,list[1::]))
p = list(map(int,input().split()))
anss = 0
for i in range(2**n):
    for j in range(M):
        ans = 0
        for k in range(N):
            if i >> k & 1 and k in K[j]:
                ans += 1
        if ans % 2 != p[j]:
            break
        else:
            anss += 1
print(ans) 
