
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;

vector < vector <ll> > vec;
ll par[15];
ll n,m;
ll dp[15][ll(pow(2,11))];
ll solve(ll i,ll dr)
{
    //cout<<i<<" "<<dr<<endl;
    if(i==n)
    {

       //cout<<dr<<" ";

        for(ll j=0;j<m;j++){
            ll c = 0;
            for(ll k=0;k<vec[j].size();k++){
                if( (dr>>(vec[j][k]-1))&1 == 1 )
                {
                    c++;
                }
            }
           // cout<<dr<<" "<<j<<" "<<c<<endl;
            if(par[j]==0){
                if(c%2 == 1){
                    return 0;
                }
            }
            else{
                if(c%2 == 0){
                    return 0;
                }
            }
        }
        return 1;

    }
    else{
        if(1){

            return   solve(i+1,dr)+solve(i+1,dr+(1<<i));


        }
        //return dp[i][dr];
    }
}

int main()
{


        cin>>n>>m;
        memset(dp,-1,sizeof(dp));
        for(ll i=0;i<m;i++)
        {
            ll k;
            cin>>k;
            vector <ll> ve;
            for(ll j=0;j<k;j++){
                ll x;
                cin>>x;
                ve.push_back(x);
            }
            vec.push_back(ve);
        }
        for(ll i=0;i<m;i++)cin>>par[i];

        cout<<solve(0,0LL)<<endl;

}
