import numpy as np
NM= list(map(int,input().split()))
N = NM[0]
M = NM[1]

k = []
S = []
for i in range(M):
    kS = list(map(int,input().split()))
    k.append(kS[0])
    S.append(kS[1:])

P = list(map(int,input().split()))
Pt = np.zeros((len(P),1))
for i in range(len(P)):
    Pt[i,0]=P[i]

ta = np.zeros((M,N))
for i in range(M):
    for j in range(len(S[i])):
        ta[i,S[i][j]-1]=1

sta = np.zeros((N,1))

count = 0

def func(k):
    global count
    global ta
    global sta
    global P
    for s1 in range(2):
        if k < N:
            sta[k] = s1
            func(k+1)
            if (np.dot(ta,sta)%2==Pt).all() and k<N-1:
                count+=1

func(0)
print(int(count))