from itertools import product
N, M = map(int, input().split())
SW = []
for _ in range(M):
    k, *s = map(int, input().split())
    SW.append([*s])
p = list(map(int, input().split()))

Onoffs = product([0, 1], repeat=N)

cnt = 0
for onoff in Onoffs:
    for i, sw in enumerate(SW):
        tmp = 0
        for j in sw:
            if onoff[j-1]:
                tmp += 1
        if tmp % 2 != p[i]:
            break
    else:
        cnt += 1

print(cnt) from itertools import product N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M SW = [] SW [] for _ in range(M):
    k, *s = map(int, input().split())
    SW.append([*s]) _ range(M) range M k, *s = map(int, input().split()) k map(int, input().split()) map int input().split() ().split () input split *s s SW.append([*s]) SW.append SW append [*s] *s s p = list(map(int, input().split())) p list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split Onoffs = product([0, 1], repeat=N) Onoffs product([0, 1], repeat=N) product [0, 1] 0 1 repeat=N repeat N cnt = 0 cnt 0 for onoff in Onoffs:
    for i, sw in enumerate(SW):
        tmp = 0
        for j in sw:
            if onoff[j-1]:
                tmp += 1
        if tmp % 2 != p[i]:
            break
    else:
        cnt += 1 onoff Onoffs for i, sw in enumerate(SW):
        tmp = 0
        for j in sw:
            if onoff[j-1]:
                tmp += 1
        if tmp % 2 != p[i]:
            break
    else:
        cnt += 1 i sw enumerate(SW) enumerate SW tmp = 0 tmp 0 for j in sw:
            if onoff[j-1]:
                tmp += 1
         j sw if onoff[j-1]:
                tmp += 1
         onoff[j-1] onoff j-1 j 1 tmp += 1 tmp 1 if tmp % 2 != p[i]:
            break
     tmp % 2 != p[i] tmp % 2 tmp 2 p[i] p i break cnt += 1 cnt 1 print(cnt) print cnt M = map(int, input().split()) map(int, input().split()) M N, M = map(int, input().split()) map(int, input().split()) N Onoffs = product([0, 1], repeat=N) product([0, 1], repeat=N) Onoffs cnt += 1 1 cnt SW = [] [] SW cnt = 0 0 cnt p = list(map(int, input().split())) list(map(int, input().split())) p tmp = 0 0 tmp tmp += 1 1 tmp k, *s = map(int, input().split()) map(int, input().split()) k
from itertools import product
N, M = map(int, input().split())
SW = []
for _ in range(M):
    k, *s = map(int, input().split())
    SW.append([*s])
p = list(map(int, input().split()))

Onoffs = product([0, 1], repeat=N)

cnt = 0
for onoff in Onoffs:
    for i, sw in enumerate(SW):
        tmp = 0
        for j in sw:
            if onoff[j-1]:
                tmp += 1
        if tmp % 2 != p[i]:
            break
    else:
        cnt += 1

print(cnt)
