#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(void) {
	int N, M;
	int counter = 0;
	cin >> N >> M;

	vector<int>k = vector<int>(M);
	vector<vector<int>>s = vector<vector<int>>(M, vector<int>(N));
	vector<int>p = vector<int>(M);
	vector<int>swt = vector<int>(N);
	vector<int>lgt = vector<int>(M);

	for (int i = 0; i < M; i++) {
		cin >> k[i];
		for (int j = 0; j < k[i]; j++) {
			cin >> s[i][j];
		}
	}

	for (int i = 0; i < M; i++) {
		cin >> p[i];
	}

	for (int i = 0; i < pow(2, N); i++) {
		int i1 = i;
		int j1 = 0;
		for (int k = 0; k < N; k++) {
			swt[k] = 0;
		}
		while (i1 > 0) {
			if (i1 % 2 == 0) {
				swt[j1] = 0;
			}
			else if (i1 % 2 == 1) {
				swt[j1] = 1;
			}
			i1 /= 2;
			j1++;
		}

		for (int j = 0; j < N; j++) {
			int count_k = 0;
			for (int k1 = 0; k1 < M; k1++) {
				//if (j < k[k1])break;
				if (s[k1][k[k1]] == j) {
					lgt[k1] += swt[k1];
				}
			}
		}

		int counter_lgt = 0;
		for (int j = 0; j < M; j++) {
			if(lgt[j] % 2 == p[j])
			counter_lgt++;
		}
		if (counter_lgt == M)
			counter++;
	}

	cout << counter << endl;
	return 0;
}