#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
constexpr int INF = 1<<30;
constexpr ll  LINF = 1LL<<60;

#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ll<<(n))

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

// a = (a+b)%MOD;
void addmod(ll& a, ll b) {
  a = (a+b)%MOD;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// x^y in O(log N)
ll pow_r(ll x, ll y) {
  assert(y>=0);

  ll ret = 1;
  while (y>0) {
    if (y%2) {
      ret = ret*x;
    }
    x *=x;
    y >>= 1;
  }

  return ret;
}
// ========== end of template ==========

vvi sets;
vi ps;

int validate(const vi& switches) {
  for (int i=0; i<int(sets.size()); i++) {
    int x = 0;
    for (auto j : sets[i]) {
      x += switches[j];
    }
//cerr << "i " << i << ", x " << x <<endl;
    if (x%2 != ps[i]) {
      return 0;
    }
  }

  return 1;
}

int main(int argc, char** argv) {
  int N, M;
  cin >> N >> M;

  sets.resize(M);

  for (int i=0; i<M; i++) {
    int k;
    cin >> k;
    sets[i] = vi(k);
    for (int j=0; j<k; j++) {
      cin >> sets[i][j];
      sets[i][j]--; // 0-indexed
    }
  }

  ps.resize(M);
  for (int i=0; i<M; i++) {
    cin >> ps[i];
  }

  int ret = 0;
  for (uint32_t i=0; i<pow_r(2, N); i++) {
    vi switches(N);
    for (int j=0; j<N; j++) {
      switches[j] = i>>j & 1u;
    }
    ret += validate(switches);

    // for (int j=0; j<N; j++) {
    //   cerr << switches[j];
    // }
    // cerr << "\nret " << ret << endl;
  }

  cout << ret << endl;


  return 0;
}
