#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
const int MAXN = 10;
int bulb[MAXN][MAXN];
int main() {
  for (int i = 0; i < MAXN; i++) {
    for (int j = 0; j < MAXN; j++) {
      bulb[i][j] = 0;
    }
  }
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int x;
      cin >> x;
      x--;
      bulb[i][x] = 1;
    }
  }
  int p[MAXN];
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  int res = 0;
  for (int mask = 1; mask < (1 << n); mask++) {
    vector<int> state;
    for (int j = 0; j < n; j++) {
      if (mask & (1 << j)) {
        state.push_back(j);
      }
    }
    debug() << " ["
            << "state"
               ": "
            << (state) << "] ";
    int ans = 0;
    for (int i = 0; i < m; i++) {
      int cnt = 0;
      for (int c : state) {
        if (bulb[i][c]) {
          cnt++;
        }
      }
      if (cnt % 2 == p[i]) ans++;
    }
    if (ans == m) res++;
  }
  cout << res << endl;
  return 0;
}
