#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){
    int n, m;
    cin >> n >> m;
    
    bool sw[m][n] = {};

    rep(i, m){
        int k;
        cin >> k;
        rep(j, k){
            int s;
            cin >> s;
            sw[i][j] = true;
        }
    }

    bool p[m];
    rep(i, m)cin >> p[i];

    int ans = 0;
    rep(i, (1<<n)){
        bool isODD[m] = {};
        rep(j, n)if(i&(1<<j)){
            rep(k, m)if(sw[k][j])isODD[k] = !isODD[k];
        }

        bool isOK = true;
        rep(j, m)if(isODD[j]!=p[j]){
            isOK = false;
            break;
        }

        if(isOK)ans++;
    }

    cout << ans << endl;
}