#include <bits/stdc++.h>
#define rep(i,l,r) for((i)=(l);(i)<(r);(i)++)
#define MOD 1000000007
#define ll long long
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int s[m][n+1],p[m],k[m],i,j;
    rep(i,0,m){
        cin>>k[i];
        rep(j,0,k[i]){
            cin>>s[i][j];
            s[i][j]--;
        }
    }
    rep(i,0,m)cin>>p[i];

    int ans=0,bit;
    rep(bit,0,1<<n){
        int ok=1;
        rep(i,0,m){
            int swi=0;
            rep(j,0,k[i]) if(bit&(1<<s[i][j]))swi++;
            if(swi%2!=p[i])ok=0;
        }
        if(ok)ans++;
    }

    cout<<ans<<endl;
}