from itertools import product

N, M = map(int, input().split())


def on_count(p):
    c = 0
    while p > 0:
        if p % 2 == 1:
            c += 1
        p //= 2
    return c


switches = []
for i in range(M):
    k, *sw = map(int, input().split())
    switches.append(sw)
P = list(map(int, input().split()))

total = 0
for pattern in product([0, 1], repeat=N):
    t = 0
    for k, indices in enumerate(switches):
        n_on = 0
        for idx in indices:
            if pattern[idx-1]:
                n_on += 1
        if n_on % 2 == P[k]:
            t += 1
    if t == M:
        total += 1
print(total) from itertools import product N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M def on_count(p):
    c = 0
    while p > 0:
        if p % 2 == 1:
            c += 1
        p //= 2
    return c on_count c = 0 c 0 while p > 0:
        if p % 2 == 1:
            c += 1
        p //= 2
     p > 0 p 0 if p % 2 == 1:
            c += 1
         p % 2 == 1 p % 2 p 2 1 c += 1 c 1 p //= 2 p 2 return c c p p switches = [] switches [] for i in range(M):
    k, *sw = map(int, input().split())
    switches.append(sw) i range(M) range M k, *sw = map(int, input().split()) k map(int, input().split()) map int input().split() ().split () input split *sw sw switches.append(sw) switches.append switches append sw P = list(map(int, input().split())) P list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split total = 0 total 0 for pattern in product([0, 1], repeat=N):
    t = 0
    for k, indices in enumerate(switches):
        n_on = 0
        for idx in indices:
            if pattern[idx-1]:
                n_on += 1
        if n_on % 2 == P[k]:
            t += 1
    if t == M:
        total += 1 pattern product([0, 1], repeat=N) product [0, 1] 0 1 repeat=N repeat N t = 0 t 0 for k, indices in enumerate(switches):
        n_on = 0
        for idx in indices:
            if pattern[idx-1]:
                n_on += 1
        if n_on % 2 == P[k]:
            t += 1
     k indices enumerate(switches) enumerate switches n_on = 0 n_on 0 for idx in indices:
            if pattern[idx-1]:
                n_on += 1
         idx indices if pattern[idx-1]:
                n_on += 1
         pattern[idx-1] pattern idx-1 idx 1 n_on += 1 n_on 1 if n_on % 2 == P[k]:
            t += 1
     n_on % 2 == P[k] n_on % 2 n_on 2 P[k] P k t += 1 t 1 if t == M:
        total += 1 t == M t M total += 1 total 1 print(total) print total total += 1 1 total N, M = map(int, input().split()) map(int, input().split()) N M = map(int, input().split()) map(int, input().split()) M P = list(map(int, input().split())) list(map(int, input().split())) P t = 0 0 t n_on += 1 1 n_on k, *sw = map(int, input().split()) map(int, input().split()) k def on_count(p):
    c = 0
    while p > 0:
        if p % 2 == 1:
            c += 1
        p //= 2
    return c def on_count(p):
    c = 0
    while p > 0:
        if p % 2 == 1:
            c += 1
        p //= 2
    return c on_count n_on = 0 0 n_on switches = [] [] switches total = 0 0 total t += 1 1 t
from itertools import product

N, M = map(int, input().split())


def on_count(p):
    c = 0
    while p > 0:
        if p % 2 == 1:
            c += 1
        p //= 2
    return c


switches = []
for i in range(M):
    k, *sw = map(int, input().split())
    switches.append(sw)
P = list(map(int, input().split()))

total = 0
for pattern in product([0, 1], repeat=N):
    t = 0
    for k, indices in enumerate(switches):
        n_on = 0
        for idx in indices:
            if pattern[idx-1]:
                n_on += 1
        if n_on % 2 == P[k]:
            t += 1
    if t == M:
        total += 1
print(total)
