N, M = map(int, input().split())
K = [list(map(int, input().split())) for _ in range(M)]
P = list(map(int, input().split()))

ans = 0
# pow(2,N)のbit全探索
for num in range(1 << N):
    # 全ての電灯を確認
    # print(num)
    flag = True
    for m in range(M):
        count_m = 0
        for j in K[m][1:]:
            if num & (1 << (j - 1)):
                count_m += 1
        # print(m, count_m, K[m], P[m])
        if count_m % 2 != P[m]:
            flag = False
            break
    # print(num, flag)
    if flag:
        ans += 1

print(ans) N, M = map(int, input().split()) N 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 K = [list(map(int, input().split())) for _ in range(M)] K [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 ans = 0 ans 0 for num in range(1 << N):
    # 全ての電灯を確認
    # print(num)
    flag = True
    for m in range(M):
        count_m = 0
        for j in K[m][1:]:
            if num & (1 << (j - 1)):
                count_m += 1
        # print(m, count_m, K[m], P[m])
        if count_m % 2 != P[m]:
            flag = False
            break
    # print(num, flag)
    if flag:
        ans += 1 num range(1 << N) range 1 << N 1 N flag = True flag True for m in range(M):
        count_m = 0
        for j in K[m][1:]:
            if num & (1 << (j - 1)):
                count_m += 1
        # print(m, count_m, K[m], P[m])
        if count_m % 2 != P[m]:
            flag = False
            break
    # print(num, flag)
     m range(M) range M count_m = 0 count_m 0 for j in K[m][1:]:
            if num & (1 << (j - 1)):
                count_m += 1
        # print(m, count_m, K[m], P[m])
         j K[m][1:] [m] K m 1: 1 if num & (1 << (j - 1)):
                count_m += 1
        # print(m, count_m, K[m], P[m])
         num & (1 << (j - 1)) num 1 << (j - 1) 1 j - 1 j 1 count_m += 1 count_m 1 if count_m % 2 != P[m]:
            flag = False
            break
    # print(num, flag)
     count_m % 2 != P[m] count_m % 2 count_m 2 P[m] P m flag = False flag False break if flag:
        ans += 1 flag ans += 1 ans 1 print(ans) print ans ans = 0 0 ans ans += 1 1 ans count_m += 1 1 count_m flag = False False flag M = map(int, input().split()) map(int, input().split()) M P = list(map(int, input().split())) list(map(int, input().split())) P N, M = map(int, input().split()) map(int, input().split()) N flag = True True flag count_m = 0 0 count_m K = [list(map(int, input().split())) for _ in range(M)] [list(map(int, input().split())) for _ in range(M)] K
N, M = map(int, input().split())
K = [list(map(int, input().split())) for _ in range(M)]
P = list(map(int, input().split()))

ans = 0
# pow(2,N)のbit全探索
for num in range(1 << N):
    # 全ての電灯を確認
    # print(num)
    flag = True
    for m in range(M):
        count_m = 0
        for j in K[m][1:]:
            if num & (1 << (j - 1)):
                count_m += 1
        # print(m, count_m, K[m], P[m])
        if count_m % 2 != P[m]:
            flag = False
            break
    # print(num, flag)
    if flag:
        ans += 1

print(ans)