#include <bits/stdc++.h>
using namespace std;
const long long LINF = 1e18L + 1;
const int INF = 1e9 + 1;
bool on[11];
int n, m;
vector<vector<int> > switches(n);
vector<int> p(m);
long long ans = 0;
void dfs(int k = 0) {
  if (k == n) {
    vector<int> times(m, 0);
    for (int i = 0; i < (n); ++i) {
      if (!on[i]) continue;
      for (int foo : switches[i]) {
        times[foo]++;
      }
    }
    for (int i = 0; i < (m); ++i) {
      if (times[i] % 2 != p[i]) return;
    }
    ans++;
    return;
  }
  dfs(k + 1);
  on[k] = true;
  dfs(k + 1);
  on[k] = false;
}
int main() {
  cin >> n >> m;
  switches.resize(n);
  for (int i = 0; i < (m); ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < (k); ++j) {
      int s;
      cin >> s;
      s--;
      switches[i].push_back(s);
    }
  }
  p.resize(m);
  for (int i = 0; i < (m); ++i) cin >> p[i];
  dfs();
  cout << ans << endl;
  return 0;
}
