var
	now,cnt,N,M,i,j,k,s:Longint;
	A:array[1..10,1..10]of Boolean;
	P:array[1..10]of Longint;
	flag:Boolean;
begin
	read(N,M);
	for i:=1 to M do begin
		read(k);
		for j:=1 to k do begin
			read(s);
			A[i,s]:=True;
		end;
	end;
	for i:=1 to M do begin
		read(P[i]);
	end;
	for i:=0 to (1<<N)-1 do begin
		flag:=True;
		for j:=1 to M do begin
			now:=0;
			for k:=1 to N do begin
				if((i>>k-1)mod 2=1)and A[j,k]then inc(now);
			end;
			if now mod 2<>P[j]mod 2 then begin
				flag:=False;
				break;
			end;
		end;
		if flag then inc(cnt);
	end;
	writeln(cnt);
end.