#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<vector<int> > s(m);
  vector<int> p(m);
  for (int i = 0; i < (int)m; ++i) {
    int k;
    scanf("%d", &k);
    s[i] = vector<int>(k);
    for (int j = 0; j < (int)k; ++j) scanf("%d", &s[i][j]);
  }
  for (int i = 0; i < (int)m; ++i) scanf("%d", &p[i]);
  int ret = 0;
  for (int i = 0; i < (int)1 << n; ++i) {
    vector<int> on(n);
    for (int j = 0; j < (int)n; ++j)
      if ((i >> j) & 1) on[j] = 1;
    bool flag = true;
    int x = 0;
    for (int j = 0; j < (int)m; ++j) {
      for (int k = 0; k < (int)s[j].size(); ++k) {
        if (on[s[j][k] - 1]) x++;
      }
      x %= 2;
      if (x != p[j]) flag = false;
      if (!flag) break;
    }
    if (flag) ret++;
  }
  cout << ret << endl;
  return 0;
}
