#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int INF = 1e9 + 7;
int N, M;
vector<int> k, p;
vector<vector<int>> s;
int ans = 0;
void dfs(vector<int> v) {
  if (v.size() == N) {
    bool flag = true;
    for (int i = (0); i < (int)M; i++) {
      int sum = 0;
      for (int j = (0); j < (int)k[i]; j++) sum += v[s[i][j]];
      if (sum % 2 != p[i]) flag = false;
    }
    if (flag) ans++;
    return;
  }
  v.push_back(0);
  dfs(v);
  v.pop_back();
  v.push_back(1);
  dfs(v);
}
int main() {
  cin >> N >> M;
  k = vector<int>(M);
  p = vector<int>(M);
  s = vector<vector<int>>(M);
  for (int i = (0); i < (int)M; i++) {
    cin >> k[i];
    for (int j = (0); j < (int)k[i]; j++) {
      int a;
      cin >> a;
      s[i].push_back(a);
    }
  }
  for (int i = (0); i < (int)M; i++) cin >> p[i];
  vector<int> v;
  dfs(v);
  cout << ans << endl;
}
