#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T chmin(T& a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T& b,T a){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template <class T> T gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T lcm(T a, T b){return a * b / gcd(a, b);}

template<class T> vector<pair<T,T>> duplicator(const vector<T>& input){
    vector<pair<T,T>> out(input.size()-1);
    rep(i,input.size()-1){
        out[i].first =input[i  ];
        out[i].second=input[i+1];
    }
    return(out);
}
vector<char> String_to_vector_char(const string& input){
    vector<char> out(input.size());
    rep(i,input.size()){
        out[i]=input[i];
    }
    return out;
}
inline bool operator<(const pii &lhs,const pii &rhs){
    return(lhs.first<rhs.first);
}

int n,m;
bitset<12> e;
map<int,vector<int>> s;
vector<int> p;
void input(){
    cin>>n>>m;
    rep(i,m){
        int k;
        cin>>k;
        rep(j,k){
            int sm;
            cin>>sm;
            s[i].push_back(sm-1);
        }
    }
    p.resize(m);
    rep(i,m){
        cin>>p[i];
    }   
}

void src(){
    vector<int> dk(m,0);
    int count=0;
    rep(i,1<<n){
        e = i;
        rep(j,m){
            if(e[j]==1){
                for(auto k:s[j]){
                    dk[k]++;
                }
            } 
        }
        for_each(dk.begin(),dk.end(),[](auto &x){x=x%2;});
        if(dk==p) count++; 
        for_each(dk.begin(),dk.end(),[](auto &x){x=0;});
    }
    cout<<count;
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
    //ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}