#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	int n,m;
	cin >> n >> m;
	int k[m],s[11][11];
	REP(i,m){
		cin >> k[i];
		REP(j,k[i]){
			cin >> s[i][j];
		}
	}
	int p[m];
	REP(i,m) cin >> p[i];
	int S[11] = {};
	int cnt = 0;
	for(S[1] = 0; S[1] <= 1; S[1]++){
		for(S[2] = 0; S[2] <= 1; S[2]++){
			for(S[3] = 0; S[3] <= 1; S[3]++){
				for(S[4] = 0; S[4] <= 1; S[4]++){
					for(S[5] = 0; S[5] <= 1; S[5]++){
						for(S[6] = 0; S[6] <= 1; S[6]++){
							for(S[7] = 0; S[7] <= 1; S[7]++){
								for(S[8] = 0; S[8] <= 1; S[8]++){
									for(S[9] = 0; S[9] <= 1; S[9]++){
										for(S[10] = 0; S[10] <= 1; S[10]++){
											int cnt_s[m] = {};
											REP(i,m){
												REP(j,k[i]){
													if(S[s[i][j]] == 1)cnt_s[i]++; 
												}
											}
											bool light = true;
											REP(i,m){
												if((cnt_s[i] % 2) != p[i]) light = false;
											}
											if(light == true) cnt++;
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	cout << cnt / pow(2, 10 - n - 1) << endl;
}