N,M=map(int, input().split())
k=[list(map(int,input().split()))for _ in range(M)]
p=list(map(int,input().split()))
import itertools
import operator
import functools
print(sum(1 for i in itertools.product([True,False],repeat=N)if functools.reduce(operator.and_,[functools.reduce(operator.xor,[i[j-1]for j in k[l][1:]])==p[l]for l in range(M)]))) 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 import itertools itertools import operator operator import functools functools functools.reduce(operator.xor,[i[j-1]for j in k[l][1:]])==p[l]for l in range(M) for l in range(M) l range(M) range M for l in range(M) functools.reduce(operator.xor,[i[j-1]for j in k[l][1:]])==p[l] functools.reduce(operator.xor,[i[j-1]for j in k[l][1:]]) functools.reduce functools reduce operator.xor operator xor [i[j-1]for j in k[l][1:]] p[l] p l print(sum(1 for i in itertools.product([True,False],repeat=N)if functools.reduce(operator.and_,[functools.reduce(operator.xor,[i[j-1]for j in k[l][1:]])==p[l]for l in range(M)]))) print sum(1 for i in itertools.product([True,False],repeat=N)if functools.reduce(operator.and_,[functools.reduce(operator.xor,[i[j-1]for j in k[l][1:]])==p[l]for l in range(M)])) sum 1 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 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()))
import itertools
import operator
import functools
print(sum(1 for i in itertools.product([True,False],repeat=N)if functools.reduce(operator.and_,[functools.reduce(operator.xor,[i[j-1]for j in k[l][1:]])==p[l]for l in range(M)])))
