#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

signed main() {
  int n,m; cin >>n >>m;
  vector<vector<int>> s(m);
  rep(i,m) {
    int k; cin >> k;
    s[i].resize(k);
    rep(j, k) cin >> s[i][j];
  }
  vector<int> p(m);
  rep(i,m) cin >> p[i];

  int ans = 0;
  rep(b, 1<<n) {
    bool ok = true;
    rep(i, m) {
      int count = 0;
      for(auto ss : s[i]) if(b & 1<< (ss-1)) count++;
      ok=(count%2 == p[i]);
      if(!ok) break;
    }
    ans += ok;
  }
  cout << ans << endl;

}
