#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int s[100][100];

int main(){
  int n,m;
  ll ans=0;
  cin >> n >> m;
  int k[m];
  rep(i,m){
    cin >> k[i];
    rep(j,k[i]){
      cin >> s[i][j];
      s[i][j]--;
    }
  }
  int p[m];
  rep(i,m)cin >> p[i];
  for (int bit = 0; bit < (1<<m); ++bit){
    int on[m]={};
        for (int i = 0; i < m; ++i) {
            if (bit & (1<<i)) { // i が bit に入るかどうか
                on[i]++;
            }
        }
    bool ok=true;
    rep(i,m){
      int cnt=0;
      rep(l,k[i]){
        if(on[s[i][l]]>0)cnt++;
      }
      if(cnt%2!=p[i])ok=false;
    }
    if(ok){
      ans++;
    }
  }
  cout << ans << endl;
return 0;}