import itertools

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


answer_count = 0
for switches in itertools.product((0, 1), repeat=N):
    on_count = 0
    for j in range(M):
        count = 0
        for i in range(N):
            if (switches[i] == 1) and (i + 1 in target_switches[j][1:]):
                count += 1
                
        if count % 2 == p[j]:
            on_count += 1
    
    if on_count == M:
        answer_count += 1

print(answer_count) import itertools itertools 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 target_switches = [list(map(int, input().split())) for _ in range(M)] target_switches [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 answer_count = 0 answer_count 0 for switches in itertools.product((0, 1), repeat=N):
    on_count = 0
    for j in range(M):
        count = 0
        for i in range(N):
            if (switches[i] == 1) and (i + 1 in target_switches[j][1:]):
                count += 1
                
        if count % 2 == p[j]:
            on_count += 1
    
    if on_count == M:
        answer_count += 1 switches itertools.product((0, 1), repeat=N) itertools.product itertools product (0, 1) 0 1 repeat=N repeat N on_count = 0 on_count 0 for j in range(M):
        count = 0
        for i in range(N):
            if (switches[i] == 1) and (i + 1 in target_switches[j][1:]):
                count += 1
                
        if count % 2 == p[j]:
            on_count += 1
    
     j range(M) range M count = 0 count 0 for i in range(N):
            if (switches[i] == 1) and (i + 1 in target_switches[j][1:]):
                count += 1
                
         i range(N) range N if (switches[i] == 1) and (i + 1 in target_switches[j][1:]):
                count += 1
                
         (switches[i] == 1) and (i + 1 in target_switches[j][1:]) switches[i] == 1 switches[i] switches i 1 i + 1 in target_switches[j][1:] i + 1 i 1 target_switches[j][1:] [j] target_switches j 1: 1 count += 1 count 1 if count % 2 == p[j]:
            on_count += 1
    
     count % 2 == p[j] count % 2 count 2 p[j] p j on_count += 1 on_count 1 if on_count == M:
        answer_count += 1 on_count == M on_count M answer_count += 1 answer_count 1 print(answer_count) print answer_count answer_count = 0 0 answer_count count = 0 0 count N, M = map(int, input().split()) map(int, input().split()) N on_count += 1 1 on_count target_switches = [list(map(int, input().split())) for _ in range(M)] [list(map(int, input().split())) for _ in range(M)] target_switches count += 1 1 count answer_count += 1 1 answer_count M = map(int, input().split()) map(int, input().split()) M p = list(map(int, input().split())) list(map(int, input().split())) p on_count = 0 0 on_count
import itertools

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


answer_count = 0
for switches in itertools.product((0, 1), repeat=N):
    on_count = 0
    for j in range(M):
        count = 0
        for i in range(N):
            if (switches[i] == 1) and (i + 1 in target_switches[j][1:]):
                count += 1
                
        if count % 2 == p[j]:
            on_count += 1
    
    if on_count == M:
        answer_count += 1

print(answer_count)