#include <iostream>
#include <vector>

using namespace std;

int main() {
		int N, M;
		cin >> N >> M;
		vector<int> sw(N);
		for (int i = 0; i < M; i++) {
				int K;
				cin >> K;
				for (int j = 0; j < K; j++) {
						int s;
						cin >> s;
						s--;
						sw[s] |= 1<<i;
				}
		}

		int p = 0;
		for (int i = 0; i < M; i++) {
				int x;
				cin >> x;
				p |= x<<i;
		}

		int ans = 0;
		for (int s = 0; s < (1<<N); s++) {
				int t = 0;
				for (int i = 0; i < N; i++) {
						if (s>>i & 1) t ^= sw[i];
				}
				if (t == p) ans++;
		}

		cout << ans << endl;

		return 0;
}
