#include <bits/stdc++.h>
using namespace std;
using ll = long long;
string char_to_string(char val) { return string(1, val); }
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> k(M);
  vector<vector<int>> s(M, vector<int>(M));
  for (int i = 0; i < M; ++i) {
    cin >> k[i];
    for (int m = 0; m < k[i]; ++m) {
      cin >> s[i][m];
    }
  }
  vector<int> p(M);
  for (int i = 0, i_len = (M); i < i_len; ++i) cin >> p[i];
  ll res = 0;
  for (int bit = 0; bit < (1 << N); ++bit) {
    bool ok = true;
    for (int i = 0; i < M; ++i) {
      int jud = 0;
      for (auto v : s[i]) {
        if (bit & (1 << v)) jud++;
      }
      if (jud % 2 != p[i]) ok = false;
    }
    if (ok) ++res;
  }
  cout << res << endl;
}
