#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, m;
  cin >> n >> m;
  vector<long long int> k[m];
  for (long long int i = 0; i < m; i++) {
    long long int kk;
    cin >> kk;
    while (kk--) {
      long long int num;
      cin >> num;
      num--;
      k[i].push_back(num);
    }
  }
  vector<long long int> p;
  for (long long int i = 0; i < m; i++) {
    long long int num;
    cin >> num;
    p.push_back(num);
  }
  long long int count = 0;
  for (long long int i = 1; i < (1 << n); i++) {
    set<long long int> s;
    for (long long int j = 0; j < m; j++) {
      if (i & 1 << j) {
        s.insert(j);
      }
    }
    debug() << " ["
            << "s"
               ": "
            << (s) << "] ";
    long long int mk = 0;
    for (long long int l = 0; l < m; l++) {
      debug() << " ["
              << "k[l]"
                 ": "
              << (k[l]) << "] ";
      long long int c = 0;
      for (long long int o = 0; o < k[l].size(); o++) {
        if (s.find(k[l][o]) != s.end()) {
          c++;
        }
      }
      long long int t = p[l];
      if (c % 2 == t) {
        mk++;
      }
    }
    debug() << " ["
            << "mk"
               ": "
            << (mk) << "] ";
    if (mk == m) {
      count++;
    }
  }
  cout << count << "\n";
  return 0;
}
