#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
const ll LINF = 0x1fffffffffffffff;
const int INF = 0x3fffffff;
const int MOD = 1000000007;
void in() {}
template <class T, class... U>
void in(T &t, U &...u) {
  cin >> t;
  in(u...);
}
void solve();
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  solve();
}
int N, M;
int s[10][10];
int p[10];
int ans = 0;
int m[10];
void dfs(int depth) {
  if (depth == N) {
    for (int i = (0); i < (M); ++i) {
      int cnt = 0;
      for (auto &x : (s[i])) {
        cnt += m[x];
      }
      if (cnt % 2 != p[i]) return;
    }
    ans++;
    return;
  }
  m[depth] = 0;
  dfs(depth + 1);
  m[depth] = 1;
  dfs(depth + 1);
}
void solve() {
  in(N, M);
  for (int i = (0); i < (M); ++i) {
    int k;
    in(k);
    for (int j = (0); j < (k); ++j) in(s[i][j]);
  }
  for (int i = (0); i < (M); ++i) in(p[i]);
  dfs(0);
  cout << (ans) << endl;
}
