#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define int long long
using namespace std;
typedef pair<int,int> P;
//void read(int &N,int &M,vector<vector<int>> &g,vector<int>&p);
signed main(){
    int N,M;
    vector<vector<int>> to(N);
    vector<int> p(N);
    cin>>N>>M;
    REP(i,M){
        int k;cin>>k;
        REP(j,k){
            int s;cin>>s;
            s--;
            to[s].push_back(i);
        }
    }
    REP(i,M) cin>>p[i];
    int ans=0;
    REP(i,1<<N){//2^nパターン列挙
        vector<int> bulb(M,0);
        REP(j,N){//スイッチjに対してビット走査
            int bit=(i>>j)&1;
            if(bit==1) REP(k,to[j].size()) bulb[to[j][k]]++;
        }
        bool ok=true;
        REP(j,M) if(bulb[j]%2!=p[j]) ok=false;
        if(ok) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

//void read(int &N,int &M,vector<vector<int>> &g,vector<int>&p){
    
}