import std.stdio, std.conv, std.string;
import std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

int DEBUG_LEVEL = 0;
void print()(){ writeln(""); }
void print(T, A ...)(T t, lazy A a){ write(t), print(a); }
void print(int level, T, A ...)(T t, lazy A a){ if(level <= DEBUG_LEVEL) print(t, a); }

void main(string[] args){
	if(args.length > 1 && args[1] == "-debug"){
		if(args.length > 2 && args[2].isNumeric) DEBUG_LEVEL = args[2].to!int;
		else DEBUG_LEVEL = 1;
	}
	
	int n = read.to!int;
	int m = read.to!int;
	
	bool[][] xs = new bool[][](m, n); // xs[i][j]: 電球iはスイッチjに制御される
	foreach(i; 0 .. m){
		int k = read.to!int;
		foreach(j; 0 .. k){
			int s = read.to!int - 1;
			xs[i][s] = 1;
		}
	}
	int[] ps;
	foreach(i; 0 .. m) ps ~= read.to!int;
	
	int cnt;
	foreach(t; 0 .. 1L<<n){
		bool flag = 1;
		foreach(i; 0 .. m){
			int q;
			foreach(j; 0 .. n){
				if(xs[i][j] && (1L<<j & t)) q += 1;
			}
			if(q % 2 != ps[i]) flag = 0;
		}
		if(flag) cnt += 1;
	}
	
	cnt.writeln;
}
