#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const long long longinf = 1LL << 60;
const long long mod = 1e9 + 7;
int bitCount(uint bits) {
  int cnt = 0;
  for (uint mask = 1; mask != 0; mask <<= 1) {
    if ((bits & mask) != 0) ++cnt;
  }
  return cnt;
}
int main() {
  int N, M;
  cin >> N;
  cin >> M;
  vector<vector<int> > sw(M + 1);
  for (int i = (int)(0); i < (int)(M); i++) {
    vector<int> v(0);
    sw[i] = v;
    int k;
    cin >> k;
    int s;
    for (int i = (int)(0); i < (int)(k); i++) {
      cin >> s;
      sw[i].push_back(s - 1);
    }
  }
  int p[M];
  for (int i = (int)(0); i < (int)(M); i++) cin >> p[i];
  int swi[M];
  for (int i = (int)(0); i < (int)(M); i++) {
    swi[i] = 0;
    for (auto itr = sw[i].begin(); itr != sw[i].end(); ++itr) {
      swi[i] += pow(2, (*itr));
    }
  }
  long long ans = 0;
  for (int i = (int)(0); i < (int)(pow(2, N)); i++) {
    int flag = 1;
    for (int j = (int)(0); j < (int)(M); j++) {
      if ((bitCount(i & swi[j]) % 2) != p[j]) {
        flag = 0;
      }
    }
    if (flag == 1) ans++;
  }
  cout << ans << endl;
  return 0;
}
