#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
bool pairCompare(const pair<string, ll>& firstElof,
                 const pair<string, ll>& secondElof) {
  if (firstElof.first != secondElof.first) {
    return firstElof.first < secondElof.first;
  } else {
    return firstElof.second > secondElof.second;
  }
}
int main() {
  ll n, m;
  cin >> n >> m;
  ll s[15][15] = {0};
  ll k[15] = {0};
  ll p[15] = {0};
  for (int i = 0; i < m; ++i) {
    cin >> k[i];
    for (int j = 0; j < k[i]; ++j) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < m; ++i) {
    cin >> p[i];
  }
  ll ans = 0;
  for (ll bit = 0; bit < pow(2, n); ++bit) {
    vector<int> v;
    bool ok = true;
    for (int i = 0; i < m; ++i) {
      if (bit & (1 << i)) {
        v.push_back(i);
      }
    }
    for (int i = 0; i < m; ++i) {
      ll cnt = 0;
      for (int j = 0; j < k[i]; ++j) {
        if (find(v.begin(), v.end(), s[i][j] - 1) != v.end()) {
          cnt++;
        }
      }
      if (cnt % 2 != p[i]) {
        ok = false;
      }
    }
    if (ok) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
