n,m = map(int,input().split())
s = []
k = []
p = []
count = 0
for i in range(m):
    q = input().split()
    k.append(int(q[0]))
    q.remove(q[0])
    s.append(q)
    #print(q)
    for j in range(k[i]):
        s[i][j] = int(q[j])
        #print(s)
    
q = input().split()
for j in range(m):
        p.append(int(q[j]))
        #count.append([0])
#入力終了

       
for i in range(pow(2,n)):
    list = []
    for o in range(n):
        list.append(i%2)
        i = i // 2
    #print(list)
    for j in range(m):
        wa = 0
        q = 0
        for l in range(k[j] ):
            wa += list[s[j][l]-1]
        if wa%2 == p[j]:
            q += 1
        else:
            break
    if q == m-1:
        count += 1

#kotae = count[0]
#for i in range(1,m):
    #kotae *= count[i]

#print(kotae)
print(count)
