N, M = list(map(int,input().split()))
K_and_Ss = []
for i in range(M):
    data = list(map(int,input().split()))
    K_and_Ss.append(data)
Ps = list(map(int,input().split()))

flag = False
x = 2**N
sum = 0
for i in range(x):
    for j in range(M): #j番目の電球がついているかを判定
        count = 0
        if flag:
            flag = False
            break
        for k in range(len(K_and_Ss[j])-1):
            if (i >> (K_and_Ss[j][k+1]-1) & 1) == 1:
                count += 1
            if k ==len(K_and_Ss[j])-2 and count % 2 == Ps[j]:
                flag = False
                if j == M-1:
                    sum += 1
            if k ==len(K_and_Ss[j])-2 and count % 2 != Ps[j] and j != M-1:
                flag = True
print(sum) N, M = list(map(int,input().split())) N list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split M K_and_Ss = [] K_and_Ss [] for i in range(M):
    data = list(map(int,input().split()))
    K_and_Ss.append(data) i range(M) range M data = list(map(int,input().split())) data list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split K_and_Ss.append(data) K_and_Ss.append K_and_Ss append data Ps = list(map(int,input().split())) Ps list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split flag = False flag False x = 2**N x 2**N 2 N sum = 0 sum 0 for i in range(x):
    for j in range(M): #j番目の電球がついているかを判定
        count = 0
        if flag:
            flag = False
            break
        for k in range(len(K_and_Ss[j])-1):
            if (i >> (K_and_Ss[j][k+1]-1) & 1) == 1:
                count += 1
            if k ==len(K_and_Ss[j])-2 and count % 2 == Ps[j]:
                flag = False
                if j == M-1:
                    sum += 1
            if k ==len(K_and_Ss[j])-2 and count % 2 != Ps[j] and j != M-1:
                flag = True i range(x) range x for j in range(M): #j番目の電球がついているかを判定
        count = 0
        if flag:
            flag = False
            break
        for k in range(len(K_and_Ss[j])-1):
            if (i >> (K_and_Ss[j][k+1]-1) & 1) == 1:
                count += 1
            if k ==len(K_and_Ss[j])-2 and count % 2 == Ps[j]:
                flag = False
                if j == M-1:
                    sum += 1
            if k ==len(K_and_Ss[j])-2 and count % 2 != Ps[j] and j != M-1:
                flag = True j range(M) range M count = 0 count 0 if flag:
            flag = False
            break
         flag flag = False flag False break for k in range(len(K_and_Ss[j])-1):
            if (i >> (K_and_Ss[j][k+1]-1) & 1) == 1:
                count += 1
            if k ==len(K_and_Ss[j])-2 and count % 2 == Ps[j]:
                flag = False
                if j == M-1:
                    sum += 1
            if k ==len(K_and_Ss[j])-2 and count % 2 != Ps[j] and j != M-1:
                flag = True k range(len(K_and_Ss[j])-1) range len(K_and_Ss[j])-1 len(K_and_Ss[j]) len K_and_Ss[j] K_and_Ss j 1 if (i >> (K_and_Ss[j][k+1]-1) & 1) == 1:
                count += 1
             (i >> (K_and_Ss[j][k+1]-1) & 1) == 1 i >> (K_and_Ss[j][k+1]-1) & 1 i >> (K_and_Ss[j][k+1]-1) i K_and_Ss[j][k+1]-1 K_and_Ss[j][k+1] [j] K_and_Ss j k+1 k 1 1 1 1 count += 1 count 1 if k ==len(K_and_Ss[j])-2 and count % 2 == Ps[j]:
                flag = False
                if j == M-1:
                    sum += 1
             k ==len(K_and_Ss[j])-2 and count % 2 == Ps[j] k ==len(K_and_Ss[j])-2 k len(K_and_Ss[j])-2 len(K_and_Ss[j]) len K_and_Ss[j] K_and_Ss j 2 count % 2 == Ps[j] count % 2 count 2 Ps[j] Ps j flag = False flag False if j == M-1:
                    sum += 1
             j == M-1 j M-1 M 1 sum += 1 sum 1 if k ==len(K_and_Ss[j])-2 and count % 2 != Ps[j] and j != M-1:
                flag = True k ==len(K_and_Ss[j])-2 and count % 2 != Ps[j] and j != M-1 k ==len(K_and_Ss[j])-2 and count % 2 != Ps[j] k ==len(K_and_Ss[j])-2 k len(K_and_Ss[j])-2 len(K_and_Ss[j]) len K_and_Ss[j] K_and_Ss j 2 count % 2 != Ps[j] count % 2 count 2 Ps[j] Ps j j != M-1 j M-1 M 1 flag = True flag True print(sum) print sum count += 1 1 count x = 2**N 2**N x M = list(map(int,input().split())) list(map(int,input().split())) M data = list(map(int,input().split())) list(map(int,input().split())) data sum += 1 1 sum Ps = list(map(int,input().split())) list(map(int,input().split())) Ps N, M = list(map(int,input().split())) list(map(int,input().split())) N sum = 0 0 sum flag = False False flag K_and_Ss = [] [] K_and_Ss flag = False False flag flag = True True flag count = 0 0 count flag = False False flag
N, M = list(map(int,input().split()))
K_and_Ss = []
for i in range(M):
    data = list(map(int,input().split()))
    K_and_Ss.append(data)
Ps = list(map(int,input().split()))

flag = False
x = 2**N
sum = 0
for i in range(x):
    for j in range(M): #j番目の電球がついているかを判定
        count = 0
        if flag:
            flag = False
            break
        for k in range(len(K_and_Ss[j])-1):
            if (i >> (K_and_Ss[j][k+1]-1) & 1) == 1:
                count += 1
            if k ==len(K_and_Ss[j])-2 and count % 2 == Ps[j]:
                flag = False
                if j == M-1:
                    sum += 1
            if k ==len(K_and_Ss[j])-2 and count % 2 != Ps[j] and j != M-1:
                flag = True
print(sum)
