import math
N, M = list(map(int, input().split()))
q = [list(map(int, input().split())) for _ in range(M)]
p = list(map(int, input().split()))

result_count = 0
for i in range(2**N):
    flag = True
    for idx, j in enumerate(q):  # 電球の数分ループ
        tmp_count = 0
        for k in j[1:]:
            if i >> (k - 1) & 1 == 1:
                tmp_count += 1
        if tmp_count % 2 != p[idx]:
            flag = False
    result_count += 1 if flag else 0

print(result_count) import math math 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 list(map(int, input().split())) for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split q = [list(map(int, input().split())) for _ in range(M)] q [list(map(int, input().split())) for _ in range(M)] p = list(map(int, input().split())) p list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split result_count = 0 result_count 0 for i in range(2**N):
    flag = True
    for idx, j in enumerate(q):  # 電球の数分ループ
        tmp_count = 0
        for k in j[1:]:
            if i >> (k - 1) & 1 == 1:
                tmp_count += 1
        if tmp_count % 2 != p[idx]:
            flag = False
    result_count += 1 if flag else 0 i range(2**N) range 2**N 2 N flag = True flag True for idx, j in enumerate(q):  # 電球の数分ループ
        tmp_count = 0
        for k in j[1:]:
            if i >> (k - 1) & 1 == 1:
                tmp_count += 1
        if tmp_count % 2 != p[idx]:
            flag = False
     idx j enumerate(q) enumerate q tmp_count = 0 tmp_count 0 for k in j[1:]:
            if i >> (k - 1) & 1 == 1:
                tmp_count += 1
         k j[1:] j 1: 1 if i >> (k - 1) & 1 == 1:
                tmp_count += 1
         i >> (k - 1) & 1 == 1 i >> (k - 1) & 1 i >> (k - 1) i k - 1 k 1 1 1 tmp_count += 1 tmp_count 1 if tmp_count % 2 != p[idx]:
            flag = False
     tmp_count % 2 != p[idx] tmp_count % 2 tmp_count 2 p[idx] p idx flag = False flag False result_count += 1 if flag else 0 result_count 1 if flag else 0 flag 1 0 print(result_count) print result_count q = [list(map(int, input().split())) for _ in range(M)] [list(map(int, input().split())) for _ in range(M)] q result_count = 0 0 result_count tmp_count += 1 1 tmp_count p = list(map(int, input().split())) list(map(int, input().split())) p result_count += 1 if flag else 0 1 if flag else 0 result_count M = list(map(int, input().split())) list(map(int, input().split())) M N, M = list(map(int, input().split())) list(map(int, input().split())) N flag = True True flag tmp_count = 0 0 tmp_count flag = False False flag
import math
N, M = list(map(int, input().split()))
q = [list(map(int, input().split())) for _ in range(M)]
p = list(map(int, input().split()))

result_count = 0
for i in range(2**N):
    flag = True
    for idx, j in enumerate(q):  # 電球の数分ループ
        tmp_count = 0
        for k in j[1:]:
            if i >> (k - 1) & 1 == 1:
                tmp_count += 1
        if tmp_count % 2 != p[idx]:
            flag = False
    result_count += 1 if flag else 0

print(result_count)
