import itertools
n,m=list(map(int,input().split()))
L=[list(map(int,input().split()))[1:] for i in range(m)]
P=list(map(int,input().split()))
cnt=0

for i in range(1<<n):
  k=1
  for p,ll in zip(P,L):
    k*=(sum([int(bin(i)[2:].zfill(n)[l-1]) for l in ll])%2==p)
  cnt+=k
print(cnt)