#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9 + 7;
int main(void) {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> s(M);
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    s[i] = vector<int>(k);
    for (int j = 0; j < k; j++) cin >> s[i][j];
  }
  vector<int> p(M);
  for (int i = 0; i < M; i++) cin >> p[i];
  int ans = 0;
  for (int i = 0; i < 1 << N; i++) {
    vector<bool> b(N);
    for (int j = 0; j < N; j++) b[j] = (i >> j) & 1;
    bool ok = true;
    for (int j = 0; j < M; j++) {
      int cnt = 0;
      for (int k = 0; k < s[j].size(); k++) {
        if (b[k]) cnt++;
      }
      if (cnt % 2 != p[j]) ok = false;
    }
    if (ok) ans++;
  }
  cout << ans << endl;
  return 0;
}
