#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <typename T>
T gcd(T a, T b) {
  if (a % b == 0) {
    return b;
  } else {
    return gcd(b, a % b);
  }
}
template <typename T>
T lcm(T a, T b) {
  return a * b / gcd(a, b);
}
int N, M;
vector<int> k;
vector<int> p;
vector<vector<int>> s(10);
int result = 0;
void print(int *bits) {
  for (int i = 0; i < N; ++i) {
    cout << bits[i] << "";
  }
  cout << endl;
}
static bool is_light(int *bits, int sw) {
  bool res = false;
  int on = 0;
  for (int i = 0; i < k[sw]; ++i) {
    if (bits[s[sw][i] - 1] == 1) {
      on++;
    }
  }
  if (p[sw] == 0) {
    if (on % 2 == 0) {
      res = true;
    }
  } else {
    if (on % 2 == 1) {
      res = true;
    }
  }
  return res;
}
static void go(int *bits, int depth) {
  if (depth == N) {
    bool light = false;
    for (int i = 0; i < M; ++i) {
      light = is_light(bits, i);
      if (!light) {
        return;
      }
    }
    result++;
    return;
  }
  bits[depth] = 0;
  go(bits, depth + 1);
  bits[depth] = 1;
  go(bits, depth + 1);
}
int main() {
  cin >> N >> M;
  for (int i = 0; i < M; ++i) {
    int t;
    cin >> t;
    k.push_back(t);
    for (int j = 0; j < k[i]; ++j) {
      cin >> t;
      s[i].push_back(t);
    }
  }
  for (int i = 0; i < M; ++i) {
    int t;
    cin >> t;
    p.push_back(t);
  }
  int bits[M];
  go(bits, 0);
  cout << result << endl;
}
