#include <iostream>
#include <sstream>
#include <vector>
#include <cassert>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <tuple>
#include <regex>
#include <map>
#include <cstdint>
#include <set>
#include <deque>
#include <bitset>

using namespace std;
using ull = unsigned long long;
using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

#define EPS (1e-7)
#define ALL(x) begin(x), end(x)


struct Light {
	vector<ll> switchNums;
	ll onValue; // スイッチが偶数個onの時に光るするなら0,奇数個なら1。
};

bool isOn(ll bit, const Light& light) {
	ll mask = 0;
	for (const auto s: light.switchNums) {
		mask |= 1LL << (s - 1);
	}
	const ll masked = bit & mask;
	const bitset<10> b(masked);
	return (b.count() % 2) == light.onValue;
}

int main() {
	ll N, M;
	cin >> N >> M;


	vector<Light> Ls(M);
	for (size_t i = 0; i < M; i++) {
		ll k;
		cin >> k;
		for (size_t j = 0; j < k; j++) {
			ll s;
			cin >> s;
			Ls[i].switchNums.push_back(s);
		}
	}
	for (size_t i = 0; i < M; i++) {
		cin >> Ls[i].onValue;
	}

	// 全パターン試す。ビットで見る
	ll ans = 0;
	for (size_t i = 0; i < 0x03FF; i++) {
		if (all_of(ALL(Ls), [i](auto l) {
			return isOn(i, l);
		})) {
			ans++;
		}
		if (i >= (1LL << N)) {
			break;
		}
	}
	cout << ans << endl;



	return 0;
}