#include <bits/stdc++.h>	
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)
#define int long long

// random_device rd; mt19937 g(rd());

using namespace std;
 
void Fast_Read_Out()
{
    ios_base::sync_with_stdio(0);
    cin.tie(), cout.tie();
}
 
void Random()
{
    unsigned int seed;                                                                        
    asm("rdtsc" : "=A" (seed));
    srand(seed);        
}
 
unsigned int Time()
{
     unsigned int time = clock() / 1000.00;                           
     return time;
}
 
const int mod = (int)1e9 + 7;
 
int id[100][100];
int cur[100];
int ans;
int k[100], p[100];

main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif		
	Fast_Read_Out();
	Random();   
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= m; i++) 
	{
		cin >> k[i];
		for(int j = 1; j <= k[i]; j++) cin >> id[i][j], id[i][j]--;
	}
	for(int i = 1; i <= m; i++) cin >> p[i];
	for(int mask = 0; mask <= (1 << n); mask++)
	{
		memset(cur, 0, sizeof cur);
		int cnt = 0;
		for(int i = 0; i < n; i++)
		{
			for(int j = 1; j <= m; j++) 
				for(int l = 1; l <= k[j]; l++) if(id[j][l] == i) cur[j] += ((mask >> i) & 1);
		}
		for(int i = 1; i <= m; i++) if(p[i] == cur[i] % 2) cnt++;
		if(cnt == m) ans++;
	}
	cout << ans;
}                                