#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
 
int main(){
    int n,m;cin>>n>>m;
    vector<vector<int>> s(m);
    rep(i,m){
        int k;cin>>k;
        rep(i,k){
            int a;cin>>a;
            s[i].insert(a-1);
        }
    }
    vector<int> p(m);
    rep(i,m) cin>>p[i];
    ////////////////
    int ans =0;
    for(int bit=0;bit<(1<<n);++bit){
        bool ok = true;
        for(int j=0;j<m;++j){
            int count = 0;
            for(int k:s[j]){
                if((bit>>k)&1)++count;
            }
        count=count%2;
        if(count!=p[j])ok=false;
        }
        if(ok)ans+=1;
    }
    cout<<ans<<endl;
}