#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

int main(){
	int n,m; cin >> n >> m;
	vector<vector<int>> s(m);
	rep(i,m){
		int k; cin >> k;
		rep(j,k){
			int t; cin >> t;
			t--;
			s[i].push_back(t);
		}
	}
	vector<int> p(m);
	rep(i,m){
		cin >> p[i];
	}
	
	int ans = 0;
	
	rep(bit, 1<<n){
		bool ok = true;
		rep(i,m){
			int count = 0;
			rep(j,s[i].size()){
				if(bit & (1 << s[i][j])) count++;
			}
			if(count % 2 != p[i]) ok = false;
		}
		if(ok) ans++;
	}
	
	cout << ans << endl;
    return 0;
}

