#include <iostream>
using namespace std;

int main()
{		
	int n, m, c = 0;
	int k[10], p[10];
	int s[10][10];

	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		cin >> k[i];

		for (int j = 0; j < k[i]; j++)
			cin >> s[i][j];
	}

	for (int i = 0; i < m; i++)
		cin >> p[i];

	for (int i = 0; i < (1 << n); i++) {
		bool f = 1;
		for (int j = 0; j < m; j++){
			int b = 0;

			for (int u = 0; u < k[j]; u++)
				if ((i & (1 << (s[j][u] - 1))) > 0)
					b++;

			if (b % 2 != p[j]) {
				f = 0;
				break;
			}
		}
		if (f)
			c++;
	}

	cout << c << endl;

	return 0;
}