#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef list<ll> listl;
typedef string str;

#define min(A, B) min(static_cast<ll>(A), static_cast<ll>(B))
#define max(A, B) max(static_cast<ll>(A), static_cast<ll>(B))

void in(ll& I)
{
	cin >> I;
}

void in(vl& I)
{
	for (auto& i : I)
	{
		cin >> i;
	}
}

void in(listl& I)
{
	for (auto& i : I)
	{
		cin >> i;
	}
}

void in(str& s)
{
	cin >> s;
}

void out(ll O)
{
	cout << O;
}

void out(vl& O)
{
	for (auto& o : O)
	{
		cout << o;
	}
}

int main()
{
	ll N;
	ll M;

	in(N);
	in(M);

	vl K(M);

	vector<vl> S(M);

	for (int i = 0; i < M; i++)
	{
		in(K[i]);
		S[i].resize(K[i]);
		in(S[i]);
	}

	vl P(M);

	in(P);

	vector<bool> B(N);

	ll NA = pow(2, N);

	ll Max = 0;

	for(int n=0;n<NA;n++)
	{
		for (int j = 0; j < N; j++)
		{
			B[j] = n & (0x1 << j);
		}

		bool ac = true;

		for (int i = 0; i < M; i++)
		{
			ll mod = 0;
			for (int j = 0; j < K[i]; j++)
			{
				mod = B[S[i][j] - 1] ? (mod + 1) % 2 : mod;
			}

			if (mod != P[i])
			{
				ac = false;
				break;
			}
		}
		if (ac)Max++;
	}

	out(Max);

	return 0;
}