#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/range/algorithm.hpp>
#define rep(i,n) for (int i=0; i< (n); ++i)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> k(m);
  boost::multi_array<int,2> s(boost::extents[m][10]);
  vector<int> p(m);
  rep(i,m){
    cin >> k[i];
    rep(j,k[i]){
      cin >> s[i][j];
    }
  }
  rep(i,m){
    cin >> p[i];
  }

  int count = 0;
  rep(state,(1<<n)){
    bool flag = true;
    rep(i,m){
      int on = 0;
      rep(j,k[i]){
        on += (state>>s[i][j])%2;
      }
      if (on%2 != p[i]) flag = false;
    }
    if (flag) count++;
  }

  cout << count << endl;

  return 0;
}
