from itertools import *
N,M = map(int,input().split())
K = [list(map(int,input().split()))[1:] for m in range(M)]
P = list(map(int,input().split()))
print(sum([all([sum([s[j-1] for j in v])%2==t for v,t in zip(K,P)]) for s in product([0,1],repeat=N)])) from itertools import * N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M list(map(int,input().split()))[1:] for m in range(M) for m in range(M) m range(M) range M for m in range(M) list(map(int,input().split()))[1:] (map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split 1: 1 K = [list(map(int,input().split()))[1:] for m in range(M)] K [list(map(int,input().split()))[1:] for m 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 all([sum([s[j-1] for j in v])%2==t for v,t in zip(K,P)]) for s in product([0,1],repeat=N) for s in product([0,1],repeat=N) s product([0,1],repeat=N) product [0,1] 0 1 repeat=N repeat N for s in product([0,1],repeat=N) all([sum([s[j-1] for j in v])%2==t for v,t in zip(K,P)]) all [sum([s[j-1] for j in v])%2==t for v,t in zip(K,P)] print(sum([all([sum([s[j-1] for j in v])%2==t for v,t in zip(K,P)]) for s in product([0,1],repeat=N)])) print sum([all([sum([s[j-1] for j in v])%2==t for v,t in zip(K,P)]) for s in product([0,1],repeat=N)]) sum [all([sum([s[j-1] for j in v])%2==t for v,t in zip(K,P)]) for s in product([0,1],repeat=N)] M = map(int,input().split()) map(int,input().split()) M K = [list(map(int,input().split()))[1:] for m in range(M)] [list(map(int,input().split()))[1:] for m in range(M)] K N,M = map(int,input().split()) map(int,input().split()) N P = list(map(int,input().split())) list(map(int,input().split())) P
from itertools import *
N,M = map(int,input().split())
K = [list(map(int,input().split()))[1:] for m in range(M)]
P = list(map(int,input().split()))
print(sum([all([sum([s[j-1] for j in v])%2==t for v,t in zip(K,P)]) for s in product([0,1],repeat=N)]))