#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;
    for (int j = 0; j < K; j++) {
      int s;
      cin >> s;
      S[i].push_back(s - 1);
    }
  }
  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++) {
    int t = i;
    vector<bool> ss(N, false);
    for (int j = 0; j < N; j++) {
      ss[j] = t % 2;
      t /= 2;
    }
    bool check = true;
    for (int j = 0; j < M; j++) {
      int n = 0;
      for (int k = 0; k < S[j].size(); k++) {
        if (ss[k]) n++;
      }
      if (n % 2 != p[j]) check = false;
    }
    if (check) ans++;
  }
  cout << ans << endl;
  return 0;
}
