
#include <iostream>
#include <algorithm>
#include <list>
#include <string>
#include < math.h>

using namespace std;





int main() {
	int ans = 0;
	int n, m;
	int k[10];
	int s[10][10];

	int lump[10];

	cin >> n >> m;

	int checktype = pow(2, n);


	for (int i = 0; i < m; i++) {
		cin >> k[i];

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

	int p[10];

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



	bool unko;
	for (int lumptype = 0; lumptype < checktype; lumptype++) {
		unko = true;
		int wk = lumptype;

		for (int i = 0; i < n; i++) {
			lump[n - 1 - i] = wk % 2;
			wk /= 2;
		}

		for (int i = 0; i < m; i++) {
			int goukei = 0;

			for (int j = 0; j < k[i]; j++) {
				goukei += lump[s[i][j]-1];
			}

			if (goukei % 2 == p[i]) {
			
				//正常

			}
			else {
				unko = false;
				break;
				//次のランプタイプに行く。
			}

		}
		//全部正常だったらこれ
		if (unko) {
			ans++;
		}


	}

	cout << ans << endl;




	return 0;




}