#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
struct less_key {
  bool operator()(pair<long long int, long long int> p1,
                  pair<long long int, long long int> p2) {
    return p1.first > p2.first ||
           (p1.first == p2.first && p1.second < p2.second);
  }
};
struct pair_hash {
 public:
  std::size_t operator()(const std::pair<unsigned long long int,
                                         unsigned long long int> &x) const {
    return std::hash<unsigned long long int>()(x.first) ^
           std::hash<unsigned long long int>()(x.second);
  }
};
const long long int mod = 1000000007ll;
const long long int smod = 998244353ll;
const long long int inf = 10000000000000007ll;
const double eps = 1e-10;
const long long int MAXN = 100005;
long long int n, m;
long long int k[MAXN];
vector<long long int> s[MAXN];
long long int p[MAXN];
bool check(vector<long long int> q) {
  for (long long int i = 1; i <= m; i++) {
    long long int t = 0;
    for (auto e : s[i]) {
      t += q[e];
    }
    if (t % 2 != p[m]) {
      return false;
    }
  }
  return true;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout.precision(15);
  cout.setf(ios::fixed);
  cin >> n >> m;
  for (long long int i = 1; i <= m; i++) {
    cin >> k[i];
    for (long long int j = 0; j < k[i]; j++) {
      long long int t;
      cin >> t;
      s[i].push_back(t);
    }
  }
  for (long long int i = 1; i <= m; i++) {
    cin >> p[i];
  }
  vector<long long int> q;
  q.resize(n + 1);
  long long int R = 0;
  for (long long int i = 0; i < (1ll << n); i++) {
    long long int t = i;
    for (long long int j = 1; j <= n; j++) {
      q[j] = t % 2;
      t /= 2;
    }
    if (check(q)) {
      R += 1;
    }
  }
  cout << R << endl;
  return 0;
}
