#include <iostream>
#include <string>
#include <vector>
#include <set>
#include<algorithm>
#include <iomanip>

using namespace std;
typedef long long ll;
///定義場所///
int i, j, k, l, m, n;
int N, M,K;
ll MOD = 1000000007;
ll ans = 0;
int S[10][10];
//関数リスト//
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}
//(注)pairの型・比較する場所(first/second)は毎回変えて使用する
bool pairCompare(const pair<ll, ll> firstElof, pair<ll, ll> secondElof)
{
	return firstElof.second > secondElof.second;
}
//////////////

void BitSearch(int depth) {

}
int main()
{
	cin >> N >> M;
	for (i = 0; i < M; i++) {
		for (j = 0; j < N; j++) {
			S[i][j] = 0;
		}
	}
	for (i = 0; i < M; i++) {
		int K;
		cin >> K;
		for (j = 0; j < K; j++) {
			int number;
			cin >> number;
			S[i][number - 1] = 1;
		}
	}
	int P[10];
	for (i = 0; i < M; i++) {
		cin >> P[i];
	}
	int copy[10][10];
	for (i = 0; i < 10; i++) {
		for (j = 0; j < 10; j++) {
			copy[i][j] = S[i][j];
		}
	}
	int a, b, c, d, e, f, g, h;
	for (a = 0; a < 2; a++) {
		for (b = 0; b < 2; b++) {
			for (c = 0; c < 2; c++) {
				for (d = 0; d < 2; d++) {
					for (e = 0; e < 2; e++) {
						for (f = 0; f < 2; f++) {
							for (g = 0; g < 2; g++) {
								for (h = 0; h < 2; h++) {
									for (i = 0; i < 2; i++) {
										for (j = 0; j < 2; j++) {
											if (a == 0) {
												for (k = 0; k < M; k++) {
													S[k][0] = 0;
												}
											}
							
											if (b == 0) {
												for (k = 0; k < M; k++) {
													S[k][1] = 0;
												}
											}
											
											if (c == 0) {
												for (k = 0; k < M; k++) {
													S[k][2] = 0;
												}
											}
											
											if (d == 0) {
												for (k = 0; k < M; k++) {
													S[k][3] = 0;
												}
											}
											
											if (e == 0) {
												for (k = 0; k < M; k++) {
													S[k][4] = 0;
												}
											}
											
											if (f == 0) {
												for (k = 0; k < M; k++) {
													S[k][5] = 0;
												}
											}
											
											if (g == 0) {
												for (k = 0; k < M; k++) {
													S[k][6] = 0;
												}
											}
											
											if (h == 0) {
												for (k = 0; k < M; k++) {
													S[k][7] = 0;
												}
											}
											
											if (i == 0) {
												for (k = 0; k < M; k++) {
													S[k][8] = 0;
												}
											}
											
											if (j == 0) {
												for (k = 0; k < M; k++) {
													S[k][9] = 0;
												}
											}
											
											bool b = true;
											for (l = 0; l < M; l++) {
												int count = 0;
												for (m = 0; m < N; m++) {
													if (S[l][m] == 1) {
														count++;
													}
												}
												if (count % 2 != P[l]) {
													b = false;
												}
											}
											if (b == true) {
												ans++;
											}
											for (l = 0; l < 10; l++) {
												for (m = 0; m < 10; m++) {
													S[l][m] = copy[l][m];
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	int Z = 10 - N;
	int Y = 1;
	for (i = 0; i < Z; i++) {
		Y *= 2;
	}
	cout << ans/Y;
}

Measured memory_bytes: 256