//  [typescript]
import * as fs from 'fs';

function main(input: string[]) {
    // param
    var n: number;
    var m: number;
    var k: number[];
    var s: number[][];
    var p: number[];
    [n, m] = input.shift().split(" ").map(x => Number(x));
    p = input.pop().split(" ").map(x => Number(x));
    s = input.map(x => x.split(" ").map(x => Number(x)));
    k = [];
    for (var ix = 0; ix < s.length; ix++) {
        k[ix] = s[ix].shift();
    }
    // loop
    var imax = 1 << n;;
    var ans = 0;
    for (var ix = 0; ix < imax; ix++) {
        // n個のスイッチ設定		
        var n_on = new Array(n);
        for (var nx = 0; nx < n; nx++) {
            if (ix & (1 << nx)) {
                n_on[nx] = 1;
            } else {
                n_on[nx] = 0;
            }
        }
        // m個の点灯確認
        var m_cnt = 0;
        for (var mx = 0; mx < m; mx++) {
            // k個のスイッチ確認
            var k_cnt = 0;
            for (var kx = 0; kx < k[mx]; kx++) {
                if (n_on[s[mx][kx] - 1] == 1) k_cnt++;
            }
            if (k_cnt % 2 == p[mx]) m_cnt++;
        }
        if (m_cnt == m) ans++;
    }
    // result
    console.log(ans);
}

// エントリポイント
// - OSによるパラメタの処理の違いを吸収
function entrypoint() {
    try {
        var input = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        console.debug = function () { };
        main(input);
    }
    catch (ex) {
        console.log("----");
        console.log("file='%s'", __filename.split("\\").slice(-1)[0]);
        console.log("----");
        const lines: string[] = [];
        // @ts-ignore
        const reader = require('readline').createInterface({
            // @ts-ignore
            input: process.stdin,
            // @ts-ignore
            output: process.stdout
        });
        reader.on('line', function (line: string) {
            lines.push(line);
        });
        reader.on('close', function () {
            input = lines;
            console.log("input=%o", input);
            console.time();
            console.log("----")
            main(input);
            console.log("----")
            console.timeEnd();
        });
    }
}
entrypoint();

// ローカルライブラリ
/*
function Math_max(arr: number[]): number { return arr.reduce(function (x, y) { return Math.max(x, y) }); }
function Math_min(arr: number[]): number { return arr.reduce(function (x, y) { return Math.min(x, y) }); }
function Math_gcd(): number {
	var f = (a, b) => b ? f(b, a % b) : a
	var ans = arguments[0]
	for (var i = 1; i < arguments.length; i++) {
		ans = f(ans, arguments[i]);
	}
	return ans
};
function Math_lcm(): number {
	var a = arguments
	var g = (n, m) => m ? g(m, n % m) : n
	var l = (n, m) => n * m / g(n, m)
	var ans = a[0]
	for (var i = 1; i < a.length; i++) {
		ans = l(ans, a[i])
	}
	return ans
}
function Math_getPrimeList(value: number): number[] {
	var ans = [];
	var size = Math.floor(Math.sqrt(value - 1)) + 1;
	var arr = new Array(size).fill(0);
	for (var i = 2; i < size; i++) {
		for (var j = i; j < size; j += i) {
			if (arr[j] == 0) arr[j] = i;
		}
	}
	for (var i = 2; i < size; i++) {
		if (arr[i] == 0) ans.push(i);
	}
	return ans;
}
function Math_getPrimeFactors(value: number, opt_count: boolean = false): any[] {
	var ans: any[] = [];
	var arr = Math_getPrimeList(value);
	arr.forEach(function (fact) {
		var count = 0;
		while (value % fact == 0) {
			value /= fact;
			count++;
		}
		if (count != 0) {
			if (opt_count) {
				ans.push([fact, count]);
			} else {
				ans.push(fact);
			}
		}
	});
	return ans;
}
*/