#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1000000007;
int N, M;
vector<int> s[10];
int p[10];
int main(void) {
  cin >> N >> M;
  int k, t;
  for (int i = 0; i < (M); i++) {
    cin >> k;
    for (int j = 0; j < (k); j++) {
      cin >> t;
      s[i].push_back(t - 1);
    }
  }
  for (int i = 0; i < (M); i++) cin >> p[i];
  int count = 0;
  int p1[10];
  for (int i = 0; i < (pow(2, N)); i++) {
    for (int j = 0; j < (M); j++) p1[j] = 0;
    for (int j = 0; j < (N); j++) {
      if (((i >> j) & 1) == 1) {
        for (int k = 0; k < s[j].size(); k++) {
          p1[s[j][k]]++;
        }
      }
    }
    bool b = true;
    for (int j = 0; j < (M); j++) b &= (p1[j] % 2 == p[j]);
    count += int(b);
  }
  cout << count << endl;
  return 0;
}
