N,M = map(int, input().split())
S = [[]for i in range(M)]
for i in range(M):
    k_s = list(map(int, input().split()))
    for j in range(len(k_s)-1):
        S[i].append(k_s[j+1])
p = list(map(int, input().split()))
Answer = 0
#print(S)

for i in range(2 ** N):
    switch = [0]*N
    for j in range(N):  # このループが一番のポイント
        a = 0
        if ((i >> j) & 1):
            a = 1

        switch[j] = a


    flag = True
    for j in range(M):
        Sum = 0
        for k in range(len(S[j])):
            #print(j,k)
            Sum += switch[S[j][k]-1]

        if (Sum%2) != p[j]:
            break

        if j == M-1:
            Answer += 1

print(Answer) N,M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M []for i in range(M) for i in range(M) i range(M) range M for i in range(M) [] S = [[]for i in range(M)] S [[]for i in range(M)] for i in range(M):
    k_s = list(map(int, input().split()))
    for j in range(len(k_s)-1):
        S[i].append(k_s[j+1]) i range(M) range M k_s = list(map(int, input().split())) k_s list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split for j in range(len(k_s)-1):
        S[i].append(k_s[j+1]) j range(len(k_s)-1) range len(k_s)-1 len(k_s) len k_s 1 S[i].append(k_s[j+1]) [i].append [i] S i append k_s[j+1] k_s j+1 j 1 p = list(map(int, input().split())) p list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split Answer = 0 Answer 0 for i in range(2 ** N):
    switch = [0]*N
    for j in range(N):  # このループが一番のポイント
        a = 0
        if ((i >> j) & 1):
            a = 1

        switch[j] = a


    flag = True
    for j in range(M):
        Sum = 0
        for k in range(len(S[j])):
            #print(j,k)
            Sum += switch[S[j][k]-1]

        if (Sum%2) != p[j]:
            break

        if j == M-1:
            Answer += 1 i range(2 ** N) range 2 ** N 2 N switch = [0]*N switch [0]*N [0] 0 N for j in range(N):  # このループが一番のポイント
        a = 0
        if ((i >> j) & 1):
            a = 1

        switch[j] = a


     j range(N) range N a = 0 a 0 if ((i >> j) & 1):
            a = 1

         (i >> j) & 1 i >> j i j 1 a = 1 a 1 switch[j] = a switch[j] switch j a flag = True flag True for j in range(M):
        Sum = 0
        for k in range(len(S[j])):
            #print(j,k)
            Sum += switch[S[j][k]-1]

        if (Sum%2) != p[j]:
            break

        if j == M-1:
            Answer += 1 j range(M) range M Sum = 0 Sum 0 for k in range(len(S[j])):
            #print(j,k)
            Sum += switch[S[j][k]-1]

         k range(len(S[j])) range len(S[j]) len S[j] S j Sum += switch[S[j][k]-1] Sum switch[S[j][k]-1] switch S[j][k]-1 S[j][k] [j] S j k 1 if (Sum%2) != p[j]:
            break

         (Sum%2) != p[j] Sum%2 Sum 2 p[j] p j break if j == M-1:
            Answer += 1 j == M-1 j M-1 M 1 Answer += 1 Answer 1 print(Answer) print Answer N,M = map(int, input().split()) map(int, input().split()) N a = 0 0 a Sum += switch[S[j][k]-1] switch[S[j][k]-1] Sum S = [[]for i in range(M)] [[]for i in range(M)] S p = list(map(int, input().split())) list(map(int, input().split())) p Sum = 0 0 Sum flag = True True flag Answer = 0 0 Answer k_s = list(map(int, input().split())) list(map(int, input().split())) k_s a = 1 1 a Answer += 1 1 Answer M = map(int, input().split()) map(int, input().split()) M switch = [0]*N [0]*N switch
N,M = map(int, input().split())
S = [[]for i in range(M)]
for i in range(M):
    k_s = list(map(int, input().split()))
    for j in range(len(k_s)-1):
        S[i].append(k_s[j+1])
p = list(map(int, input().split()))
Answer = 0
#print(S)

for i in range(2 ** N):
    switch = [0]*N
    for j in range(N):  # このループが一番のポイント
        a = 0
        if ((i >> j) & 1):
            a = 1

        switch[j] = a


    flag = True
    for j in range(M):
        Sum = 0
        for k in range(len(S[j])):
            #print(j,k)
            Sum += switch[S[j][k]-1]

        if (Sum%2) != p[j]:
            break

        if j == M-1:
            Answer += 1

print(Answer)
