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

int main() {
  int n, m, s = 0;
  cin >> n >> m;
  vector<vector<int>> v(m);
  vector<int> p(m);
  rep(i, m){
    int k;
    cin >> k;
    rep(j, k){
      int r;
      cin >> r;
      v[i].push_back(r-1);
    }
  }
  rep(i, m) cin >> p[i];
  rep(i, 1 << n){
    bool b = 1;
    rep(j, m){
      int a = 0;
      rep(l, v[j].size()) if(i & 1 << v[j][l]) ++a;
      if(a % 2 != p[j]) b = 0;
    }
    if(b) ++s;
  }
  cout << s << endl;
  return 0;
}