import numpy as np
N,M = map(int, input().split())
S = []
for i in range(M):
    k,*s = map(int, input().split())
    T = [0]*N
    for j in s:
        T[j-1]=1
    S.append(T)
P = list(map(int, input().split()))
ans =0
for x in range(2**N):
    y = format(x,"0{}b".format(N))
    z = list(map(int,y))
    if all(np.dot(den,z)%2==P[nmb] for nmb,den in enumerate(S)):
        ans +=1
            
print(ans)    import numpy as np numpy N,M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M S = [] S [] for i in range(M):
    k,*s = map(int, input().split())
    T = [0]*N
    for j in s:
        T[j-1]=1
    S.append(T) i range(M) range M k,*s = map(int, input().split()) k map(int, input().split()) map int input().split() ().split () input split *s s T = [0]*N T [0]*N [0] 0 N for j in s:
        T[j-1]=1
     j s T[j-1]=1 T[j-1] T j-1 j 1 1 S.append(T) S.append S append T P = list(map(int, input().split())) P list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split ans =0 ans 0 for x in range(2**N):
    y = format(x,"0{}b".format(N))
    z = list(map(int,y))
    if all(np.dot(den,z)%2==P[nmb] for nmb,den in enumerate(S)):
        ans +=1
             x range(2**N) range 2**N 2 N y = format(x,"0{}b".format(N)) y format(x,"0{}b".format(N)) format x "0{}b".format(N) "0{}b".format "0{}b" format N z = list(map(int,y)) z list(map(int,y)) list map(int,y) map int y if all(np.dot(den,z)%2==P[nmb] for nmb,den in enumerate(S)):
        ans +=1
             all(np.dot(den,z)%2==P[nmb] for nmb,den in enumerate(S)) all np.dot(den,z)%2==P[nmb] np.dot(den,z)%2 np.dot(den,z) np.dot np dot den z 2 P[nmb] P nmb ans +=1 ans 1 print(ans) print ans T = [0]*N [0]*N T y = format(x,"0{}b".format(N)) format(x,"0{}b".format(N)) y N,M = map(int, input().split()) map(int, input().split()) N ans +=1 1 ans S = [] [] S M = map(int, input().split()) map(int, input().split()) M k,*s = map(int, input().split()) map(int, input().split()) k ans =0 0 ans P = list(map(int, input().split())) list(map(int, input().split())) P z = list(map(int,y)) list(map(int,y)) z
import numpy as np
N,M = map(int, input().split())
S = []
for i in range(M):
    k,*s = map(int, input().split())
    T = [0]*N
    for j in s:
        T[j-1]=1
    S.append(T)
P = list(map(int, input().split()))
ans =0
for x in range(2**N):
    y = format(x,"0{}b".format(N))
    z = list(map(int,y))
    if all(np.dot(den,z)%2==P[nmb] for nmb,den in enumerate(S)):
        ans +=1
            
print(ans)   